Compiler warnings: variable length array used

This commit is contained in:
Shahram Najm 2019-12-30 13:04:31 +00:00
parent 2b93ef50ee
commit 01cf5902b9
3 changed files with 6 additions and 3 deletions

View File

@ -118,7 +118,7 @@ int main(int argc, char **argv)
}
{
pthread_t workers[NUM_THREADS];
pthread_t* workers = malloc(NUM_THREADS * sizeof(pthread_t));
for (i = 0; i < NUM_THREADS; i++) {
struct v *data = (struct v *) malloc(sizeof(struct v));
data->number = i;
@ -139,6 +139,7 @@ int main(int argc, char **argv)
pthread_join(workers[i], NULL);
}
}
free (workers);
}
return 0;

View File

@ -79,7 +79,7 @@ int main(int argc, char **argv)
}
{
pthread_t workers[NUM_THREADS];
pthread_t* workers = malloc(NUM_THREADS * sizeof(pthread_t));
for (i = 0; i < NUM_THREADS; i++) {
struct v *data = (struct v *) malloc(sizeof(struct v));
data->number = i;
@ -99,6 +99,7 @@ int main(int argc, char **argv)
pthread_join(workers[i], NULL);
}
}
free (workers);
}
return 0;

View File

@ -127,7 +127,7 @@ int main(int argc, char **argv)
}
{
pthread_t workers[NUM_THREADS];
pthread_t* workers = malloc(NUM_THREADS * sizeof(pthread_t));
for (i = 0; i < NUM_THREADS; i++) {
struct v *data = (struct v *) malloc(sizeof(struct v));
data->number = i;
@ -148,6 +148,7 @@ int main(int argc, char **argv)
pthread_join(workers[i], NULL);
}
}
free (workers);
}
return 0;