diff --git a/circular-buffer.c b/circular-buffer.c index b79db30..99fe89f 100644 --- a/circular-buffer.c +++ b/circular-buffer.c @@ -104,6 +104,8 @@ int main(int argc, char *argv[]) { /* Add one element. */ elem_t *one = malloc(sizeof(elem_t)); + if (!one) + dienomem(); one->foo = 23; cb_write(test_cb, one); free(one); @@ -111,6 +113,8 @@ int main(int argc, char *argv[]) { /* Read the one element. */ elem_t *oneback = malloc(sizeof(elem_t)); + if (!oneback) + dienomem(); cb_read(test_cb, oneback); assert(oneback->foo == 23); free(oneback); @@ -118,6 +122,8 @@ int main(int argc, char *argv[]) { /* Fill the buffer. */ elem_t *e = malloc(sizeof(elem_t)); + if (!e) + dienomem(); for (int i = 1; i <= CB_SIZE; i++) { e->foo = i; cb_write(test_cb, e);