return p;
}
-void *
-cbdataInternalFree(void *p, const char *file, int line)
+void
+cbdataRealFree(cbdata *c, const char *file, const int line)
{
- cbdata *c;
-#if HASHED_CBDATA
- c = (cbdata *) hash_lookup(cbdata_htable, p);
-#else
- c = (cbdata *) (((char *) p) - cbdata::Offset);
-#endif
-#if USE_CBDATA_DEBUG
- debugs(45, 3, p << " " << file << ":" << line);
-#else
- debugs(45, 9, p);
-#endif
-
- c->check(__LINE__);
- assert(c->valid);
- c->valid = 0;
-#if USE_CBDATA_DEBUG
-
- c->addHistory("Free", file, line);
-#endif
-
- if (c->locks) {
- debugs(45, 9, p << " has " << c->locks << " locks, not freeing");
- return NULL;
- }
+ void *p = c;
--cbdataCount;
debugs(45, 9, "Freeing " << p);
#if USE_CBDATA_DEBUG
-
dlinkDelete(&c->link, &cbdataEntries);
#endif
#if HASHED_CBDATA
hash_remove_link(cbdata_htable, &c->hash);
#if USE_CBDATA_DEBUG
- debugs(45, 3, "Call delete " << (void*)c << " " << file << ":" << line);
+ debugs(45, 3, "Call delete " << p << " " << file << ":" << line);
#endif
delete c;
- cbdata_index[theType].pool->freeOne((void *)p);
#else
#if USE_CBDATA_DEBUG
- debugs(45, 3, "Call cbdata::~cbdata() " << (void*)c << " " << file << ":" << line);
+ debugs(45, 3, "Call cbdata::~cbdata() " << p << " " << file << ":" << line);
#endif
c->cbdata::~cbdata();
- cbdata_index[theType].pool->freeOne(c);
#endif
+ cbdata_index[theType].pool->freeOne(p);
+}
+
+void *
+cbdataInternalFree(void *p, const char *file, int line)
+{
+ cbdata *c;
+#if HASHED_CBDATA
+ c = (cbdata *) hash_lookup(cbdata_htable, p);
+#else
+ c = (cbdata *) (((char *) p) - cbdata::Offset);
+#endif
+#if USE_CBDATA_DEBUG
+ debugs(45, 3, p << " " << file << ":" << line);
+#else
+ debugs(45, 9, p);
+#endif
+
+ c->check(__LINE__);
+ assert(c->valid);
+ c->valid = 0;
+#if USE_CBDATA_DEBUG
+
+ c->addHistory("Free", file, line);
+#endif
+
+ if (c->locks) {
+ debugs(45, 9, p << " has " << c->locks << " locks, not freeing");
+ return NULL;
+ }
+
+ cbdataRealFree(c, file, line);
return NULL;
}
return;
}
- --cbdataCount;
-
- debugs(45, 9, "Freeing " << p);
-
-#if USE_CBDATA_DEBUG
-
- dlinkDelete(&c->link, &cbdataEntries);
-
-#endif
-
- /* This is ugly. But: operator delete doesn't get
- * the type parameter, so we can't use that
- * to free the memory.
- * So, we free it ourselves.
- * Note that this means a non-placement
- * new would be a seriously bad idea.
- * Lastly, if we where a templated class,
- * we could use the normal delete operator
- * and it would Just Work. RBC 20030902
- */
- cbdata_type theType = c->type;
-#if HASHED_CBDATA
- hash_remove_link(cbdata_htable, &c->hash);
-#if USE_CBDATA_DEBUG
- debugs(45, 3, "Call delete " << (void*)c << " " << file << ":" << line);
-#endif
- delete c;
- cbdata_index[theType].pool->freeOne((void *)p);
-#else
-#if USE_CBDATA_DEBUG
- debugs(45, 3, "Call cbdata::~cbdata() " << (void*)c << " " << file << ":" << line);
-#endif
- c->cbdata::~cbdata();
- cbdata_index[theType].pool->freeOne(c);
-#endif
+ cbdataRealFree(c, file, line);
}
int