X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b060880e24efd3d1862694ab007a8b98c42adcc7..ebec9c6104a6bbe60b7bf4586baeaf0b88f53505:/examples/sthread/pthread-producer-consumer.c diff --git a/examples/sthread/pthread-producer-consumer.c b/examples/sthread/pthread-producer-consumer.c index cf69840fd8..52a0080256 100644 --- a/examples/sthread/pthread-producer-consumer.c +++ b/examples/sthread/pthread-producer-consumer.c @@ -57,7 +57,7 @@ static void* consumer(void* id) int main(int argc, char** argv) { - char opt; + int opt; while ((opt = getopt(argc, argv, "c:C:p:P:q")) != -1) { switch (opt) { case 'q': @@ -75,7 +75,7 @@ int main(int argc, char** argv) case 'P': ProducerCount = atoi(optarg); break; - case '?': + default: /* '?' */ printf("unknown option: %c\n", optopt); break; } @@ -87,7 +87,7 @@ int main(int argc, char** argv) sem_init(&empty, 0, BufferSize); sem_init(&full, 0, 0); - int* ids = malloc(sizeof(int) * ((ProducerCount + ConsumerCount))); + int* ids = malloc(sizeof(int) * (ProducerCount + ConsumerCount)); for (int i = 0; i < ProducerCount + ConsumerCount; i++) ids[i] = i + 1; // The identity of each thread (for debug messages) @@ -107,6 +107,7 @@ int main(int argc, char** argv) free(pro); free(con); free(buffer); + free(ids); return 0; }