clean structure before use

This commit is contained in:
tonton th 2020-06-05 10:54:20 +02:00
parent b9919b09e5
commit af35f158cd

View File

@ -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));