mirror of
https://github.com/TheAlgorithms/C
synced 2024-11-25 14:59:36 +03:00
more mallocs
This commit is contained in:
parent
4b07f0f6fc
commit
9451beb977
@ -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
|
||||
|
@ -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(+ \
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user