clean structure before use
This commit is contained in:
parent
b9919b09e5
commit
af35f158cd
12
bubulles.c
12
bubulles.c
@ -45,7 +45,7 @@ Bubulle *array;
|
|||||||
fprintf(stderr, "+++ %s '%s' %d 0x%X\n", __func__, name, sz, unused);
|
fprintf(stderr, "+++ %s '%s' %d 0x%X\n", __func__, name, sz, unused);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (NULL==(bblptr = malloc(sizeof(BBList)))) {
|
if (NULL==(bblptr = calloc(1, sizeof(BBList)))) {
|
||||||
fprintf(stderr, "no mem available in %s\n", __func__);
|
fprintf(stderr, "no mem available in %s\n", __func__);
|
||||||
return NULL;
|
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) {
|
if (where->fidx > where->size) {
|
||||||
/* this is a very bad fatal error */
|
/* this is a very bad fatal error */
|
||||||
fprintf(stderr, "%s : overflow in BBList at %p\n", __func__, where);
|
fprintf(stderr, "%s : overflow in BBList at %p\n", __func__, where);
|
||||||
|
#if MUST_ABORT
|
||||||
abort();
|
abort();
|
||||||
}
|
#endif
|
||||||
|
|
||||||
if (where->fidx > where->size) {
|
|
||||||
/* array is full */
|
|
||||||
#if DEBUG_LEVEL
|
|
||||||
fprintf(stderr, "%s : array of %p is full\n", __func__, where);
|
|
||||||
#endif
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
memcpy(&where->bbs[where->fidx], what, sizeof(Bubulle));
|
memcpy(&where->bbs[where->fidx], what, sizeof(Bubulle));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user