more sanity check, who are untested
This commit is contained in:
parent
5e0b3eeaa5
commit
3fba5b69a9
38
bubulles.c
38
bubulles.c
@ -1,5 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
bubulles.c
|
---------- bubulles.c ----------------------------
|
||||||
|
|
||||||
|
some functions for managing bubulles in a 3D space.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -65,7 +67,7 @@ if (NULL==(array = calloc(sz, sizeof(Bubulle)))) {
|
|||||||
|
|
||||||
bblptr->bbs = array;
|
bblptr->bbs = array;
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL
|
||||||
fprintf(stderr, "\t\tbblptr is at %p\n", bblptr);
|
fprintf(stderr, "\tbblptr is at %p\n", bblptr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return bblptr;
|
return bblptr;
|
||||||
@ -76,7 +78,7 @@ int free_bubulles(BBList *bbl, int k)
|
|||||||
|
|
||||||
if (NULL == bbl->bbs) {
|
if (NULL == bbl->bbs) {
|
||||||
fprintf(stderr, "%s : array ptr is null\n", __func__);
|
fprintf(stderr, "%s : array ptr is null\n", __func__);
|
||||||
#if MUST_ABORT
|
#ifdef MUST_ABORT
|
||||||
abort();
|
abort();
|
||||||
#endif
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
@ -100,7 +102,7 @@ fprintf(stderr, ">>> %s ( %p %d )\n", __func__, where, idx);
|
|||||||
if ( (idx < 0) || (idx > where->fidx) ) {
|
if ( (idx < 0) || (idx > where->fidx) ) {
|
||||||
fprintf(stderr, "%s : idx %d out of range on %p\n",
|
fprintf(stderr, "%s : idx %d out of range on %p\n",
|
||||||
__func__, idx, where);
|
__func__, idx, where);
|
||||||
#if MUST_ABORT
|
#ifdef MUST_ABORT
|
||||||
abort();
|
abort();
|
||||||
#endif
|
#endif
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -181,6 +183,14 @@ return 0;
|
|||||||
int peek_bubulle(BBList *from, Bubulle *to, int idx)
|
int peek_bubulle(BBList *from, Bubulle *to, int idx)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (NULL==from) {
|
||||||
|
fprintf(stderr, "in %s, *from is null\n", __func__);
|
||||||
|
#ifdef MUST_ABORT
|
||||||
|
abort();
|
||||||
|
#endif
|
||||||
|
return -5;
|
||||||
|
}
|
||||||
|
|
||||||
if ((idx < 0) || (idx > from->size)) {
|
if ((idx < 0) || (idx > from->size)) {
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL
|
||||||
fprintf(stderr, "%s : idx %d out of range\n", __func__, idx);
|
fprintf(stderr, "%s : idx %d out of range\n", __func__, idx);
|
||||||
@ -190,7 +200,6 @@ if ((idx < 0) || (idx > from->size)) {
|
|||||||
|
|
||||||
memcpy(to, &from->bbs[idx], sizeof(Bubulle));
|
memcpy(to, &from->bbs[idx], sizeof(Bubulle));
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
@ -203,6 +212,14 @@ int fprint_bubulles(FILE *fp, char *title, BBList *bbl, int flags)
|
|||||||
int idx;
|
int idx;
|
||||||
Bubulle *ar;
|
Bubulle *ar;
|
||||||
|
|
||||||
|
if (NULL == bbl) {
|
||||||
|
fprintf(stderr, "in %s, *bbl is NULL\n", __func__);
|
||||||
|
#ifdef MUST_ABORT
|
||||||
|
abort();
|
||||||
|
#endif
|
||||||
|
return -5;
|
||||||
|
}
|
||||||
|
|
||||||
ar = bbl->bbs;
|
ar = bbl->bbs;
|
||||||
|
|
||||||
#if DEBUG_LEVEL > 1
|
#if DEBUG_LEVEL > 1
|
||||||
@ -243,7 +260,10 @@ int idx;
|
|||||||
|
|
||||||
if (NULL == what) {
|
if (NULL == what) {
|
||||||
fprintf(stderr, "SHIT HAPPEN IN %s\n", __func__);
|
fprintf(stderr, "SHIT HAPPEN IN %s\n", __func__);
|
||||||
|
#ifdef MUST_ABORT
|
||||||
abort();
|
abort();
|
||||||
|
#endif
|
||||||
|
return -5;
|
||||||
}
|
}
|
||||||
|
|
||||||
ar = what->bbs; /* get the bubble array addr */
|
ar = what->bbs; /* get the bubble array addr */
|
||||||
@ -311,6 +331,14 @@ return 0;
|
|||||||
int print_bbox(BBox *bbox, int k)
|
int print_bbox(BBox *bbox, int k)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (NULL==bbox) {
|
||||||
|
fprintf(stderr, "in %s, *bbox is NULL\n", __func__);
|
||||||
|
#ifdef MUST_ABORT
|
||||||
|
abort();
|
||||||
|
#endif
|
||||||
|
return -5;
|
||||||
|
}
|
||||||
|
|
||||||
printf("%9.6f %9.6f %9.6f %9.6f %9.6f %9.6f\n",
|
printf("%9.6f %9.6f %9.6f %9.6f %9.6f %9.6f\n",
|
||||||
bbox->minX, bbox->minY, bbox->minZ,
|
bbox->minX, bbox->minY, bbox->minZ,
|
||||||
bbox->maxX, bbox->maxY, bbox->maxZ);
|
bbox->maxX, bbox->maxY, bbox->maxZ);
|
||||||
|
Loading…
Reference in New Issue
Block a user