more mallocs

This commit is contained in:
Krishna Vedala 2020-04-23 20:53:53 -04:00
parent 4b07f0f6fc
commit 9451beb977
No known key found for this signature in database
GPG Key ID: BA19ACF8FC8792F7
4 changed files with 7 additions and 4 deletions

View File

@ -19,7 +19,7 @@ int main(int argc, char *argv[])
unsigned short max_digits = 0, max_idx_number = 0;
clock_t start_time = clock();
unsigned short deno;
short deno;
#ifdef _OPENMP
#pragma omp for
#endif

View File

@ -79,7 +79,8 @@ uint64_t sigma2(uint64_t N)
**/
uint64_t sigma(uint64_t N)
{
uint64_t s, sum = 0, i;
uint64_t s, sum = 0;
int64_t i;
#ifdef _OPENMP
#pragma omp parallel for reduction(+ \

View File

@ -25,7 +25,7 @@ int main()
l = a[i];
}
int b[l + 1];
int *b = (int *)malloc((l + 1) * sizeof(int));
memset(b, 0, (l + 1) * sizeof(b[0]));
for (i = 0; i < n; i++)
@ -44,5 +44,6 @@ int main()
}
free(a);
free(b);
return 0;
}

View File

@ -20,7 +20,7 @@ int MAX(int *ar, int size)
void countSort(int *arr, int n, int place)
{
int i, freq[range] = {0};
int output[n];
int *output = (int *)malloc(n * sizeof(int));
// Store count of occurences in freq[]
for (i = 0; i < n; i++)
@ -40,6 +40,7 @@ void countSort(int *arr, int n, int place)
// Copy the output array to arr[], so it contains numbers according to the current digit
for (i = 0; i < n; i++)
arr[i] = output[i];
free(output);
}
/*This is where the sorting of the array takes place