Skip to content

Commit

Permalink
more mallocs
Browse files Browse the repository at this point in the history
  • Loading branch information
kvedala committed Apr 24, 2020
1 parent 4b07f0f commit 9451beb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion project_euler/Problem 26/sol1.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion project_euler/Problem 401/sol1.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(+ \
Expand Down
3 changes: 2 additions & 1 deletion sorting/counting_Sort.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand All @@ -44,5 +44,6 @@ int main()
}

free(a);
free(b);
return 0;
}
3 changes: 2 additions & 1 deletion sorting/radix_sort_2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand All @@ -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
Expand Down

0 comments on commit 9451beb

Please sign in to comment.