diff --git a/bubulles.c b/bubulles.c index b988627..16f4b49 100644 --- a/bubulles.c +++ b/bubulles.c @@ -45,7 +45,7 @@ Bubulle *array; fprintf(stderr, "+++ %s '%s' %d 0x%X\n", __func__, name, sz, unused); #endif -if (NULL==(bblptr = malloc(sizeof(BBList)))) { +if (NULL==(bblptr = calloc(1, sizeof(BBList)))) { fprintf(stderr, "no mem available in %s\n", __func__); return NULL; } @@ -142,16 +142,12 @@ fprintf(stderr, "XYZ %f %f %f\n", what->p.x, what->p.y, what->p.z); if (where->fidx > where->size) { /* this is a very bad fatal error */ fprintf(stderr, "%s : overflow in BBList at %p\n", __func__, where); +#if MUST_ABORT abort(); - } - -if (where->fidx > where->size) { - /* array is full */ -#if DEBUG_LEVEL - fprintf(stderr, "%s : array of %p is full\n", __func__, where); -#endif +#endif return -1; } + memcpy(&where->bbs[where->fidx], what, sizeof(Bubulle));