diff --git a/src/libCom/bucketLib.c b/src/libCom/bucketLib.c index 269c61d44..71ced7d5e 100644 --- a/src/libCom/bucketLib.c +++ b/src/libCom/bucketLib.c @@ -28,6 +28,7 @@ * Modification Log: * ----------------- * .01 091493 joh fixed overzealous parameter check + * .02 121693 joh added bucketFree() */ @@ -169,11 +170,36 @@ unsigned indexWidth; pb->nEntries, sizeof(ITEMPTR)); if(!pb->pTable){ + free(pb); return NULL; } return pb; } + +/* + * bucketFree() + */ +#ifdef __STDC__ +int bucketFree(BUCKET *prb) +#else +int bucketFree(prb) +BUCKET *prb; +#endif +{ + /* + * deleting a bucket with entries in use + * will cause memory leaks and is not allowed + */ + if(prb->nInUse){ + return BUCKET_FAILURE; + } + + free(prb->pTable); + free(prb); + + return BUCKET_SUCCESS; +} /* diff --git a/src/libCom/bucketLib/bucketLib.c b/src/libCom/bucketLib/bucketLib.c index 269c61d44..71ced7d5e 100644 --- a/src/libCom/bucketLib/bucketLib.c +++ b/src/libCom/bucketLib/bucketLib.c @@ -28,6 +28,7 @@ * Modification Log: * ----------------- * .01 091493 joh fixed overzealous parameter check + * .02 121693 joh added bucketFree() */ @@ -169,11 +170,36 @@ unsigned indexWidth; pb->nEntries, sizeof(ITEMPTR)); if(!pb->pTable){ + free(pb); return NULL; } return pb; } + +/* + * bucketFree() + */ +#ifdef __STDC__ +int bucketFree(BUCKET *prb) +#else +int bucketFree(prb) +BUCKET *prb; +#endif +{ + /* + * deleting a bucket with entries in use + * will cause memory leaks and is not allowed + */ + if(prb->nInUse){ + return BUCKET_FAILURE; + } + + free(prb->pTable); + free(prb); + + return BUCKET_SUCCESS; +} /*