From: hno <> Date: Tue, 20 Mar 2001 08:10:25 +0000 (+0000) Subject: cbdataFree rewritten to have a single thread of execution with no X-Git-Tag: SQUID_3_0_PRE1~1565 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c29316a4ab614f28a8542a0f1c9c1f6520d1d2ae;p=thirdparty%2Fsquid.git cbdataFree rewritten to have a single thread of execution with no void data (only pointers). --- diff --git a/src/cbdata.cc b/src/cbdata.cc index 85630f1d51..89ffa7b75d 100644 --- a/src/cbdata.cc +++ b/src/cbdata.cc @@ -1,6 +1,6 @@ /* - * $Id: cbdata.cc,v 1.38 2001/03/03 10:39:31 hno Exp $ + * $Id: cbdata.cc,v 1.39 2001/03/20 01:10:25 hno Exp $ * * DEBUG: section 45 Callback Data Registry * ORIGINAL AUTHOR: Duane Wessels @@ -175,13 +175,11 @@ cbdataInternalAlloc(cbdata_type type) return (void *) &p->data; } -void +void * cbdataInternalFree(void *p) { cbdata *c; FREE *free_func; - if (!p) - return; debug(45, 3) ("cbdataFree: %p\n", p); c = (cbdata *) (((char *) p) - OFFSET_OF(cbdata, data)); assert(c->y == c); @@ -189,7 +187,7 @@ cbdataInternalFree(void *p) if (c->locks) { debug(45, 3) ("cbdataFree: %p has %d locks, not freeing\n", p, c->locks); - return; + return NULL; } cbdataCount--; debug(45, 3) ("cbdataFree: Freeing %p\n", p); @@ -197,6 +195,7 @@ cbdataInternalFree(void *p) if (free_func) free_func((void *) p); memPoolFree(cbdata_index[c->type].pool, c); + return NULL; } int diff --git a/src/defines.h b/src/defines.h index e4808fbc4b..c3cd1ef46d 100644 --- a/src/defines.h +++ b/src/defines.h @@ -1,6 +1,6 @@ /* - * $Id: defines.h,v 1.90 2001/03/03 10:39:31 hno Exp $ + * $Id: defines.h,v 1.91 2001/03/20 01:10:25 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -282,7 +282,7 @@ /* cbdata macros */ #define cbdataAlloc(type) ((type *)cbdataInternalAlloc(CBDATA_##type)) -#define cbdataFree(var) (var = (cbdataInternalFree(var), NULL)) +#define cbdataFree(var) (var = (var != NULL ? cbdataInternalFree(var): NULL)) #define CBDATA_TYPE(type) static cbdata_type CBDATA_##type = 0 #define CBDATA_GLOBAL_TYPE(type) cbdata_type CBDATA_##type #define CBDATA_INIT_TYPE(type) (CBDATA_##type ? 0 : (CBDATA_##type = cbdataAddType(CBDATA_##type, #type, sizeof(type), NULL))) diff --git a/src/protos.h b/src/protos.h index 8066b44dc6..3b8f443fcf 100644 --- a/src/protos.h +++ b/src/protos.h @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.400 2001/03/03 10:39:33 hno Exp $ + * $Id: protos.h,v 1.401 2001/03/20 01:10:25 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -110,7 +110,7 @@ extern void cbdataLock(const void *p); extern void cbdataUnlock(const void *p); #endif /* Note: Allocations is done using the cbdataAlloc macro */ -extern void cbdataInternalFree(void *p); +extern void *cbdataInternalFree(void *p); extern int cbdataValid(const void *p); extern void cbdataInitType(cbdata_type type, char *label, int size, FREE * free_func); extern cbdata_type cbdataAddType(cbdata_type type, char *label, int size, FREE * free_func);