Browse Source

sizeof pointer instead of long int

master
Robby Zambito 2 months ago
parent
commit
344252bd70
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      day1/1/c/main.c

+ 2
- 2
day1/1/c/main.c View File

@ -32,7 +32,7 @@ size_t getNums(long int **nums, FILE *stream) {
size_t resLen = 0;
size_t resCapacity = 10;
*nums = (long int*) malloc(resCapacity * sizeof(long int));
*nums = (long int*) malloc(resCapacity * sizeof(long int *));
if ((*nums) == NULL) {
perror("Failed to allocate nums\n");
exit(EXIT_FAILURE);
@ -43,7 +43,7 @@ size_t getNums(long int **nums, FILE *stream) {
// Double capacity of the result array
if (resCapacity == resLen) {
resCapacity *= 2;
long int *temp = (long int*) malloc(resCapacity * sizeof(long int));
long int *temp = (long int*) malloc(resCapacity * sizeof(long int *));
if (temp == NULL) {
perror("Failed to allocate temp\n");
exit(EXIT_FAILURE);

Loading…
Cancel
Save