void data (only pointers).
/*
- * $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
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);
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);
if (free_func)
free_func((void *) p);
memPoolFree(cbdata_index[c->type].pool, c);
+ return NULL;
}
int
/*
- * $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/
/* 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)))
/*
- * $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/
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);