]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
cbdata now have a per-type free function rather than per allocation.
authorhno <>
Sat, 3 Mar 2001 17:39:29 +0000 (17:39 +0000)
committerhno <>
Sat, 3 Mar 2001 17:39:29 +0000 (17:39 +0000)
Changes to the API:

To initialize a new CBDATA type with a free function:

   CBDATA_INIT_TYPE_FREECB(typename, freefunction);

To allocate a cbdata structure

   var = cbdataAlloc(typename);
   (was CBDATA_ALLOC(typename, freefunc) )

46 files changed:
doc/Programming-Guide/prog-guide.sgml
src/acl.cc
src/asn.cc
src/auth/basic/auth_basic.cc
src/auth/digest/auth_digest.cc
src/auth/ntlm/auth_ntlm.cc
src/cache_cf.cc
src/cbdata.cc
src/client_side.cc
src/comm.cc
src/defines.h
src/enums.h
src/errorpage.cc
src/forward.cc
src/fqdncache.cc
src/fs/aufs/store_dir_aufs.cc
src/fs/aufs/store_io_aufs.cc
src/fs/coss/store_dir_coss.cc
src/fs/coss/store_io_coss.cc
src/fs/diskd/store_dir_diskd.cc
src/fs/diskd/store_io_diskd.cc
src/fs/ufs/store_dir_ufs.cc
src/fs/ufs/store_io_ufs.cc
src/ftp.cc
src/gopher.cc
src/helper.cc
src/http.cc
src/ident.cc
src/ipcache.cc
src/neighbors.cc
src/net_db.cc
src/peer_digest.cc
src/peer_select.cc
src/protos.h
src/redirect.cc
src/repl/heap/store_repl_heap.cc
src/repl/lru/store_repl_lru.cc
src/ssl.cc
src/stat.cc
src/store_client.cc
src/store_digest.cc
src/store_swapout.cc
src/tunnel.cc
src/urn.cc
src/wais.cc
src/whois.cc

index be443093edf50df18d8986860f21892bf09bde80..a19550009408020b74193ca7fc2875c00bf8a745 100644 (file)
@@ -2,7 +2,7 @@
 <article>
 <title>Squid Programmers Guide</title>
 <author>Duane Wessels, Squid Developers
-<date>$Id: prog-guide.sgml,v 1.35 2001/01/31 22:16:36 hno Exp $</date>
+<date>$Id: prog-guide.sgml,v 1.36 2001/03/03 10:39:29 hno Exp $</date>
 
 <abstract>
 Squid is a WWW Cache application developed by the National Laboratory
@@ -2411,7 +2411,7 @@ coupling between the storage layer and the replacement policy.
 <verb>
        type_of_data callback_data;
        ...
-       callback_data = CBDATA_ALLOC(type_of_data, free_handler);
+       callback_data = cbdataAlloc(type_of_data);
        ...
        cbdataLock(callback_data);
        fooOperationStart(bar, callback_func, callback_data);
@@ -2427,7 +2427,7 @@ coupling between the storage layer and the replacement policy.
        With this scheme, nothing bad happens if <tt/cbdataFree/ gets called
        before <tt/cbdataUnlock/:
 <verb>
-       callback_data = CBDATA_ALLOC(...);
+       callback_data = cbdataAlloc(...);
        ...
        cbdataLock(callback_data);
        fooOperationStart(bar, callback_func, callback_data);
@@ -2449,7 +2449,7 @@ coupling between the storage layer and the replacement policy.
        <P>
        To add new module specific data types to the allocator one uses the
        macros CBDATA_TYPE and CBDATA_INIT_TYPE. These creates a local cbdata
-       definition (file or block scope). Any CBDATA_ALLOC calls must be made
+       definition (file or block scope). Any cbdataAlloc calls must be made
        within this scope. However, cbdataFree might be called from anywhere.
 
 <verb>
@@ -2463,6 +2463,8 @@ coupling between the storage layer and the replacement policy.
         * (can be called multiple times with only a minimal overhead)
         */
        CBDATA_INIT_TYPE(type_of_data);
+       /* Or if a free function is associated with the data type */
+       CBDATA_INIT_TYPE_FREECB(type_of_data, free_function);
 </verb>
 
        <P>
@@ -2476,10 +2478,6 @@ coupling between the storage layer and the replacement policy.
        extern CBDATA_GLOBAL_TYPE(type_of_data);        /* CBDATA_UNDEF */
 </verb>
 
-       <P>
-       TODO: Restructure the free function so there is one free function
-       associated with the whole cbdata type rather than per allocation.
-
 <!-- %%%% Chapter : CACHE MANAGER %%%% -->
 <sect>Cache Manager
 
index b978e98bb3e88ab5bd935a599a170e8a34cbe885..d1983e3c1b454142b328262dec9fb8e7ce70ac19 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: acl.cc,v 1.249 2001/02/23 20:59:50 hno Exp $
+ * $Id: acl.cc,v 1.250 2001/03/03 10:39:30 hno Exp $
  *
  * DEBUG: section 28    Access Control
  * AUTHOR: Duane Wessels
@@ -967,7 +967,7 @@ aclParseAccessLine(acl_access ** head)
        debug(28, 0) ("aclParseAccessLine: missing 'allow' or 'deny'.\n");
        return;
     }
-    A = CBDATA_ALLOC(acl_access, NULL);
+    A = cbdataAlloc(acl_access);
 
     if (!strcmp(t, "allow"))
        A->allow = 1;
@@ -1933,7 +1933,7 @@ aclChecklistCreate(const acl_access * A,
 {
     int i;
     aclCheck_t *checklist;
-    checklist = CBDATA_ALLOC(aclCheck_t, NULL);
+    checklist = cbdataAlloc(aclCheck_t);
     checklist->access_list = A;
     /*
      * aclCheck() makes sure checklist->access_list is a valid
index cbe98e318b990f82096196e7f920ef639b32768d..93ed133ce0bbfc09ff70e9583b570008f6171e36 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: asn.cc,v 1.70 2001/02/07 19:04:08 hno Exp $
+ * $Id: asn.cc,v 1.71 2001/03/03 10:39:30 hno Exp $
  *
  * DEBUG: section 53    AS Number handling
  * AUTHOR: Duane Wessels, Kostas Anagnostakis
@@ -187,7 +187,7 @@ asnCacheStart(int as)
     StoreEntry *e;
     request_t *req;
     ASState *asState;
-    asState = CBDATA_ALLOC(ASState, NULL);
+    asState = cbdataAlloc(ASState);
     debug(53, 3) ("asnCacheStart: AS %d\n", as);
     snprintf(asres, 4096, "whois://%s/!gAS%d", Config.as_whois_server, as);
     asState->as_number = as;
index d3081dccd5f99c1296b3ebc64e84e157dce5a4d1..c0208ad2bae38f4c74403394e6f33840b3b42583 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: auth_basic.cc,v 1.6 2001/02/07 18:56:53 hno Exp $
+ * $Id: auth_basic.cc,v 1.7 2001/03/03 10:39:36 hno Exp $
  *
  * DEBUG: section 29    Authenticator
  * AUTHOR: Duane Wessels
@@ -378,6 +378,7 @@ static void
 authBasicDataFree(basic_data * basic_auth)
 {
 }
+
 #endif
 
 static auth_user_t *
@@ -588,7 +589,7 @@ authenticateBasicStart(auth_user_request_t * auth_user_request, RH * handler, vo
        cbdataLock(data);
        return;
     } else {
-       r = CBDATA_ALLOC(authenticateStateData, NULL);
+       r = cbdataAlloc(authenticateStateData);
        r->handler = handler;
        cbdataLock(data);
        r->data = data;
index ae909dcb5e4b55eb2d5e913e53adf993ad570473..71c5c0251db8a95a5f2522a0d99b4e6cf23fe584 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: auth_digest.cc,v 1.1 2001/01/31 22:16:41 hno Exp $
+ * $Id: auth_digest.cc,v 1.2 2001/03/03 10:39:36 hno Exp $
  *
  * DEBUG: section 29    Authenticator
  * AUTHOR: Robert Collins
@@ -200,7 +200,7 @@ authenticateDigestNonceDelete(digest_nonce_h * nonce)
     }
 }
 
-void 
+void
 authenticateDigestNonceSetup()
 {
     if (!digest_nonce_pool)
@@ -212,7 +212,7 @@ authenticateDigestNonceSetup()
     }
 }
 
-void 
+void
 authenticateDigestNonceShutdown()
 {
     /* 
@@ -235,7 +235,7 @@ authenticateDigestNonceShutdown()
     debug(29, 2) ("authenticateDigestNonceShutdown: Nonce cache shutdown\n");
 }
 
-void 
+void
 authenticateDigestNonceReconfigure()
 {
 }
@@ -690,7 +690,7 @@ authenticateDigestAuthenticateUser(auth_user_request_t * auth_user_request, requ
     return;
 }
 
-int 
+int
 authenticateDigestDirection(auth_user_request_t * auth_user_request)
 {
     digest_request_h *digest_request;
@@ -1313,7 +1313,7 @@ authenticateDigestStart(auth_user_request_t * auth_user_request, RH * handler, v
        handler(data, NULL);
        return;
     }
-    r = CBDATA_ALLOC(authenticateStateData, NULL);
+    r = cbdataAlloc(authenticateStateData);
     r->handler = handler;
     cbdataLock(data);
     r->data = data;
index 31079c1e074d0bca9227a6d9c20c5976c482ec2e..dd31a26b08cebf8c2c2f7cfe37a23fea0c70a954 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: auth_ntlm.cc,v 1.6 2001/01/31 22:16:43 hno Exp $
+ * $Id: auth_ntlm.cc,v 1.7 2001/03/03 10:39:36 hno Exp $
  *
  * DEBUG: section 29    NTLM Authenticator
  * AUTHOR: Robert Collins
@@ -625,7 +625,7 @@ authenticateNTLMStart(auth_user_request_t * auth_user_request, RH * handler, voi
        return;
     }
 #ifdef NTLMHELPPROTOCOLV2
-    r = CBDATA_ALLOC(authenticateStateData, NULL);
+    r = cbdataAlloc(authenticateStateData);
     r->handler = handler;
     cbdataLock(data);
     r->data = data;
@@ -663,7 +663,7 @@ authenticateNTLMStart(auth_user_request_t * auth_user_request, RH * handler, voi
        debug(29, 9) ("authenticateNTLMStart: helper '%d' assigned\n", server);
        /* valid challenge? */
        if ((server == NULL) || !authenticateNTLMValidChallenge(helperstate)) {
-           r = CBDATA_ALLOC(authenticateStateData, NULL);
+           r = cbdataAlloc(authenticateStateData);
            r->handler = handler;
            cbdataLock(data);
            r->data = data;
@@ -687,7 +687,7 @@ authenticateNTLMStart(auth_user_request_t * auth_user_request, RH * handler, voi
 
        break;
     case AUTHENTICATE_STATE_RESPONSE:
-       r = CBDATA_ALLOC(authenticateStateData, NULL);
+       r = cbdataAlloc(authenticateStateData);
        r->handler = handler;
        cbdataLock(data);
        r->data = data;
index ae23fc855e6fa06cf0c73683e57a981f26be3ced..35123e4ec7dd3188c6c2d080056cfa06dca504d7 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: cache_cf.cc,v 1.377 2001/02/23 20:59:50 hno Exp $
+ * $Id: cache_cf.cc,v 1.378 2001/03/03 10:39:30 hno Exp $
  *
  * DEBUG: section 3     Configuration File Parsing
  * AUTHOR: Harvest Derived
@@ -380,7 +380,7 @@ configDoConfigure(void)
     if (Config.Wais.relayHost) {
        if (Config.Wais.peer)
            cbdataFree(Config.Wais.peer);
-       Config.Wais.peer = CBDATA_ALLOC(peer, peerDestroy);
+       Config.Wais.peer = cbdataAlloc(peer);
        Config.Wais.peer->host = xstrdup(Config.Wais.relayHost);
        Config.Wais.peer->http_port = Config.Wais.relayPort;
     }
@@ -778,7 +778,7 @@ dump_http_header_access(StoreEntry * entry, const char *name, header_mangler hea
     int i;
     for (i = 0; i < HDR_ENUM_END; i++) {
        if (header[i].access_list != NULL) {
-           storeAppendPrintf(entry, "%s ",name);
+           storeAppendPrintf(entry, "%s ", name);
            dump_acl_access(entry, httpHeaderNameById(i),
                header[i].access_list);
        }
@@ -811,9 +811,9 @@ parse_http_header_access(header_mangler header[])
     if (id != HDR_ENUM_END) {
        parse_acl_access(&header[id].access_list);
     } else {
-       char *next_string = t + strlen(t) -1;
+       char *next_string = t + strlen(t) - 1;
        *next_string = 'A';
-       *(next_string+1) = ' ';
+       *(next_string + 1) = ' ';
        for (i = 0; i < HDR_ENUM_END; i++) {
            char *new_string = xstrdup(next_string);
            strtok(new_string, w_space);
@@ -1246,7 +1246,7 @@ parse_peer(peer ** head)
     char *token = NULL;
     peer *p;
     int i;
-    p = CBDATA_ALLOC(peer, peerDestroy);
+    p = cbdataAlloc(peer);
     p->http_port = CACHE_HTTP_PORT;
     p->icp.port = CACHE_ICP_PORT;
     p->weight = 1;
index ea1f661eeea936c5094ecc65cd06b18dba63cb85..85630f1d51343aacbffba8e2f698ed67c1ea7d01 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: cbdata.cc,v 1.37 2001/01/31 21:46:04 hno Exp $
+ * $Id: cbdata.cc,v 1.38 2001/03/03 10:39:31 hno Exp $
  *
  * DEBUG: section 45    Callback Data Registry
  * ORIGINAL AUTHOR: Duane Wessels
@@ -71,8 +71,7 @@ static int cbdataCount = 0;
 typedef struct _cbdata {
     int valid;
     int locks;
-    CBDUNL *free_func;
-    int type;                  /* move to CBDATA_DEBUG with type argument to cbdataFree */
+    int type;
 #if CBDATA_DEBUG
     const char *file;
     int line;
@@ -87,36 +86,40 @@ typedef struct _cbdata {
 
 static OBJH cbdataDump;
 
-static MemPool **cbdata_memory_pool = NULL;
+struct {
+    MemPool *pool;
+    FREE *free_func;
+}     *cbdata_index = NULL;
 int cbdata_types = 0;
 
 #define OFFSET_OF(type, member) ((int)(char *)&((type *)0L)->member)
 
 void
-cbdataInitType(cbdata_type type, char *name, int size)
+cbdataInitType(cbdata_type type, char *name, int size, FREE * free_func)
 {
     char *label;
     if (type >= cbdata_types) {
-       cbdata_memory_pool = xrealloc(cbdata_memory_pool, (type + 1) * sizeof(*cbdata_memory_pool));
-       memset(&cbdata_memory_pool[cbdata_types], 0,
-           (type + 1 - cbdata_types) * sizeof(*cbdata_memory_pool));
+       cbdata_index = xrealloc(cbdata_index, (type + 1) * sizeof(*cbdata_index));
+       memset(&cbdata_index[cbdata_types], 0,
+           (type + 1 - cbdata_types) * sizeof(*cbdata_index));
        cbdata_types = type + 1;
     }
-    if (cbdata_memory_pool[type])
+    if (cbdata_index[type].pool)
        return;
     label = xmalloc(strlen(name) + 20);
     snprintf(label, strlen(name) + 20, "cbdata %s (%d)", name, (int) type);
     assert(OFFSET_OF(cbdata, data) == (sizeof(cbdata) - sizeof(((cbdata *) NULL)->data)));
-    cbdata_memory_pool[type] = memPoolCreate(label, size + OFFSET_OF(cbdata, data));
+    cbdata_index[type].pool = memPoolCreate(label, size + OFFSET_OF(cbdata, data));
+    cbdata_index[type].free_func = free_func;
 }
 
 cbdata_type
-cbdataAddType(cbdata_type type, char *name, int size)
+cbdataAddType(cbdata_type type, char *name, int size, FREE * free_func)
 {
     if (type)
        return type;
     type = cbdata_types;
-    cbdataInitType(type, name, size);
+    cbdataInitType(type, name, size, free_func);
     return type;
 }
 
@@ -127,7 +130,8 @@ cbdataInit(void)
     cachemgrRegister("cbdata",
        "Callback Data Registry Contents",
        cbdataDump, 0, 1);
-#define CREATE_CBDATA(type) cbdataInitType(CBDATA_##type, #type, sizeof(type))
+#define CREATE_CBDATA(type) cbdataInitType(CBDATA_##type, #type, sizeof(type), NULL)
+#define CREATE_CBDATA_FREE(type, free_func) cbdataInitType(CBDATA_##type, #type, sizeof(type), free_func)
     CREATE_CBDATA(acl_access);
     CREATE_CBDATA(aclCheck_t);
     CREATE_CBDATA(clientHttpRequest);
@@ -140,27 +144,25 @@ cbdataInit(void)
     CREATE_CBDATA(statefulhelper);
     CREATE_CBDATA(helper_stateful_server);
     CREATE_CBDATA(HttpStateData);
-    CREATE_CBDATA(peer);
+    CREATE_CBDATA_FREE(peer, peerDestroy);
     CREATE_CBDATA(ps_state);
     CREATE_CBDATA(RemovalPolicy);
     CREATE_CBDATA(RemovalPolicyWalker);
     CREATE_CBDATA(RemovalPurgeWalker);
     CREATE_CBDATA(store_client);
-    CREATE_CBDATA(storeIOState);
 }
 
 void *
 #if CBDATA_DEBUG
-cbdataInternalAllocDbg(cbdata_type type, CBDUNL * free_func, const char *file, int line)
+cbdataInternalAllocDbg(cbdata_type type, const char *file, int line)
 #else
-cbdataInternalAlloc(cbdata_type type, CBDUNL * free_func)
+cbdataInternalAlloc(cbdata_type type)
 #endif
 {
     cbdata *p;
     assert(type > 0 && type < cbdata_types);
-    p = memPoolAlloc(cbdata_memory_pool[type]);
+    p = memPoolAlloc(cbdata_index[type].pool);
     p->type = type;
-    p->free_func = free_func;
     p->valid = 1;
     p->locks = 0;
 #if CBDATA_DEBUG
@@ -174,11 +176,13 @@ cbdataInternalAlloc(cbdata_type type, CBDUNL * free_func)
 }
 
 void
-cbdataFree(void *p)
+cbdataInternalFree(void *p)
 {
     cbdata *c;
+    FREE *free_func;
+    if (!p)
+       return;
     debug(45, 3) ("cbdataFree: %p\n", p);
-    assert(p);
     c = (cbdata *) (((char *) p) - OFFSET_OF(cbdata, data));
     assert(c->y == c);
     c->valid = 0;
@@ -189,9 +193,22 @@ cbdataFree(void *p)
     }
     cbdataCount--;
     debug(45, 3) ("cbdataFree: Freeing %p\n", p);
-    if (c->free_func)
-       c->free_func((void *) p);
-    memPoolFree(cbdata_memory_pool[c->type], c);
+    free_func = cbdata_index[c->type].free_func;
+    if (free_func)
+       free_func((void *) p);
+    memPoolFree(cbdata_index[c->type].pool, c);
+}
+
+int
+cbdataLocked(const void *p)
+{
+    cbdata *c;
+    assert(p);
+    c = (cbdata *) (((char *) p) - OFFSET_OF(cbdata, data));
+    assert(c->y == c);
+    debug(45, 3) ("cbdataLocked: %p = %d\n", p, c->locks);
+    assert(c != NULL);
+    return c->locks;
 }
 
 void
@@ -223,6 +240,7 @@ cbdataUnlock(const void *p)
 #endif
 {
     cbdata *c;
+    FREE *free_func;
     if (p == NULL)
        return;
     c = (cbdata *) (((char *) p) - OFFSET_OF(cbdata, data));
@@ -239,9 +257,10 @@ cbdataUnlock(const void *p)
        return;
     cbdataCount--;
     debug(45, 3) ("cbdataUnlock: Freeing %p\n", p);
-    if (c->free_func)
-       c->free_func((void *) p);
-    memPoolFree(cbdata_memory_pool[c->type], c);
+    free_func = cbdata_index[c->type].free_func;
+    if (free_func)
+       free_func((void *) p);
+    memPoolFree(cbdata_index[c->type].pool, c);
 }
 
 int
index 9f03ee92b0086e661516c26c810fca72728f3636..619417eebb04434eea72403cf3acf3c3ce98ed3e 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side.cc,v 1.530 2001/03/01 23:02:31 wessels Exp $
+ * $Id: client_side.cc,v 1.531 2001/03/03 10:39:31 hno Exp $
  *
  * DEBUG: section 33    Client-side Routines
  * AUTHOR: Duane Wessels
@@ -2302,7 +2302,7 @@ static clientHttpRequest *
 parseHttpRequestAbort(ConnStateData * conn, const char *uri)
 {
     clientHttpRequest *http;
-    http = CBDATA_ALLOC(clientHttpRequest, NULL);
+    http = cbdataAlloc(clientHttpRequest);
     http->conn = conn;
     http->start = current_time;
     http->req_sz = conn->in.offset;
@@ -2441,7 +2441,7 @@ parseHttpRequest(ConnStateData * conn, method_t * method_p, int *status,
     assert(prefix_sz <= conn->in.offset);
 
     /* Ok, all headers are received */
-    http = CBDATA_ALLOC(clientHttpRequest, NULL);
+    http = cbdataAlloc(clientHttpRequest);
     http->http_ver = http_ver;
     http->conn = conn;
     http->start = current_time;
@@ -3074,7 +3074,7 @@ httpAccept(int sock, void *data)
            break;
        }
        debug(33, 4) ("httpAccept: FD %d: accepted\n", fd);
-       connState = CBDATA_ALLOC(ConnStateData, NULL);
+       connState = cbdataAlloc(ConnStateData);
        connState->peer = peer;
        connState->log_addr = peer.sin_addr;
        connState->log_addr.s_addr &= Config.Addrs.client_netmask.s_addr;
index f332d1b7bd6be1020a1990ef906cd5dbe5cf94ea..76a092da581b56b36a26976a3172fffde712b089 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: comm.cc,v 1.316 2001/02/23 19:42:36 wessels Exp $
+ * $Id: comm.cc,v 1.317 2001/03/03 10:39:31 hno Exp $
  *
  * DEBUG: section 5     Socket Functions
  * AUTHOR: Harvest Derived
@@ -232,7 +232,7 @@ commConnectStart(int fd, const char *host, u_short port, CNCB * callback, void *
 {
     ConnectStateData *cs;
     debug(5, 3) ("commConnectStart: FD %d, %s:%d\n", fd, host, (int) port);
-    cs = CBDATA_ALLOC(ConnectStateData, NULL);
+    cs = cbdataAlloc(ConnectStateData);
     cs->fd = fd;
     cs->host = xstrdup(host);
     cs->port = port;
index 4088d253260277aba7ce5c19011f24bfe2bef2e8..e4808fbc4b7156dedac178ce22eb258af7d24d47 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: defines.h,v 1.89 2001/01/12 00:37:16 wessels Exp $
+ * $Id: defines.h,v 1.90 2001/03/03 10:39:31 hno Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
 #endif
 
 /* cbdata macros */
-#define CBDATA_ALLOC(type, unl) ((type *)cbdataInternalAlloc(CBDATA_##type, unl))
+#define cbdataAlloc(type) ((type *)cbdataInternalAlloc(CBDATA_##type))
+#define cbdataFree(var) (var = (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))))
+#define CBDATA_INIT_TYPE(type) (CBDATA_##type ? 0 : (CBDATA_##type = cbdataAddType(CBDATA_##type, #type, sizeof(type), NULL)))
+#define CBDATA_INIT_TYPE_FREECB(type, free_func)       (CBDATA_##type ? 0 : (CBDATA_##type = cbdataAddType(CBDATA_##type, #type, sizeof(type), free_func)))
 
 #ifndef O_TEXT
 #define O_TEXT 0
index 500bdf02bb3be4bdd63997418a0a9d9772f1d31f..783fb8adac0d93e62f6c60e342a820dfabd3ca98 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: enums.h,v 1.187 2001/02/18 11:16:51 hno Exp $
+ * $Id: enums.h,v 1.188 2001/03/03 10:39:31 hno Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -753,6 +753,5 @@ typedef enum {
     CBDATA_RemovalPolicyWalker,
     CBDATA_RemovalPurgeWalker,
     CBDATA_store_client,
-    CBDATA_storeIOState,
     CBDATA_FIRST_CUSTOM_TYPE = 1000
 } cbdata_type;
index ea244f2b1db3969e92b221addd33441fd2e56354..2c64294997748285a75a5cca81018b4167efe08e 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: errorpage.cc,v 1.162 2001/01/12 00:37:17 wessels Exp $
+ * $Id: errorpage.cc,v 1.163 2001/03/03 10:39:31 hno Exp $
  *
  * DEBUG: section 4     Error Generation
  * AUTHOR: Duane Wessels
@@ -235,7 +235,7 @@ ErrorState *
 errorCon(err_type type, http_status status)
 {
     ErrorState *err;
-    err = CBDATA_ALLOC(ErrorState, NULL);
+    err = cbdataAlloc(ErrorState);
     err->page_id = type;       /* has to be reset manually if needed */
     err->type = type;
     err->http_status = status;
index d2fa080552cbdb251c19bee44ffb509c8a740ae2..3def2973931f6baebd028fa902f25e3b82a5ace3 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: forward.cc,v 1.80 2001/01/12 00:37:17 wessels Exp $
+ * $Id: forward.cc,v 1.81 2001/03/03 10:39:31 hno Exp $
  *
  * DEBUG: section 17    Request Forwarding
  * AUTHOR: Duane Wessels
@@ -544,7 +544,7 @@ fwdStart(int fd, StoreEntry * e, request_t * r)
     default:
        break;
     }
-    fwdState = CBDATA_ALLOC(FwdState, NULL);
+    fwdState = cbdataAlloc(FwdState);
     fwdState->entry = e;
     fwdState->client_fd = fd;
     fwdState->server_fd = -1;
index bfa646d6ed331de2307c482f946adeec27796326..deef6e0f630a552d135e86ef6769dc5b1916ffd1 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: fqdncache.cc,v 1.147 2001/02/23 20:59:51 hno Exp $
+ * $Id: fqdncache.cc,v 1.148 2001/03/03 10:39:31 hno Exp $
  *
  * DEBUG: section 35    FQDN Cache
  * AUTHOR: Harvest Derived
@@ -387,7 +387,7 @@ fqdncache_nbgethostbyaddr(struct in_addr addr, FQDNH * handler, void *handlerDat
     f->handlerData = handlerData;
     cbdataLock(handlerData);
     f->request_time = current_time;
-    c = CBDATA_ALLOC(generic_cbdata, NULL);
+    c = cbdataAlloc(generic_cbdata);
     c->data = f;
 #if USE_DNSSERVERS
     dnsSubmit(hashKeyStr(&f->hash), fqdncacheHandleReply, c);
index 31d7aa1b4e530398d2bc787cedb430a2ae2ade4c..b43488672164b3e9bfa63d06b7fdf7bf1fc61b8d 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir_aufs.cc,v 1.31 2001/02/19 23:10:06 hno Exp $
+ * $Id: store_dir_aufs.cc,v 1.32 2001/03/03 10:39:37 hno Exp $
  *
  * DEBUG: section 47    Store Directory Routines
  * AUTHOR: Duane Wessels
@@ -829,7 +829,7 @@ storeAufsDirRebuild(SwapDir * sd)
     FILE *fp;
     EVH *func = NULL;
     CBDATA_INIT_TYPE(RebuildState);
-    rb = CBDATA_ALLOC(RebuildState, NULL);
+    rb = cbdataAlloc(RebuildState);
     rb->sd = sd;
     rb->speed = opt_foreground_rebuild ? 1 << 30 : 50;
     /*
index 838d96089d9095a651b04be5453f200b5e34e9a2..f3fc995428aa683cce8a24a0d4777217d3fdbe0e 100644 (file)
@@ -22,6 +22,8 @@ static int storeAufsSomethingPending(storeIOState *);
 static int storeAufsKickWriteQueue(storeIOState * sio);
 static CBDUNL storeAufsIOFreeEntry;
 
+CBDATA_TYPE(storeIOState);
+
 /* === PUBLIC =========================================================== */
 
 /* open for reading */
@@ -51,7 +53,8 @@ storeAufsOpen(SwapDir * SD, StoreEntry * e, STFNCB * file_callback,
        return NULL;
     }
 #endif
-    sio = CBDATA_ALLOC(storeIOState, storeAufsIOFreeEntry);
+    CBDATA_INIT_TYPE_FREECB(storeIOState, storeAufsIOFreeEntry);
+    sio = cbdataAlloc(storeIOState);
     sio->fsstate = memPoolAlloc(aio_state_pool);
     ((aiostate_t *) (sio->fsstate))->fd = -1;
     ((aiostate_t *) (sio->fsstate))->flags.opening = 1;
@@ -105,7 +108,8 @@ storeAufsCreate(SwapDir * SD, StoreEntry * e, STFNCB * file_callback, STIOCB * c
        return NULL;
     }
 #endif
-    sio = CBDATA_ALLOC(storeIOState, storeAufsIOFreeEntry);
+    CBDATA_INIT_TYPE_FREECB(storeIOState, storeAufsIOFreeEntry);
+    sio = cbdataAlloc(storeIOState);
     sio->fsstate = memPoolAlloc(aio_state_pool);
     ((aiostate_t *) (sio->fsstate))->fd = -1;
     ((aiostate_t *) (sio->fsstate))->flags.opening = 1;
index 606d1382d1f4685fbbfb6d1e5090c061b9dc0a58..7982c0c3866448d74adbdac756ff293da3fc51cb 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir_coss.cc,v 1.19 2001/02/10 16:40:41 hno Exp $
+ * $Id: store_dir_coss.cc,v 1.20 2001/03/03 10:39:37 hno Exp $
  *
  * DEBUG: section 81    Store COSS Directory Routines
  * AUTHOR: Eric Stern
@@ -339,7 +339,7 @@ storeCossDirRebuild(SwapDir * sd)
     FILE *fp;
     EVH *func = NULL;
     CBDATA_INIT_TYPE(RebuildState);
-    rb = CBDATA_ALLOC(RebuildState, NULL);
+    rb = cbdataAlloc(RebuildState);
     rb->sd = sd;
     rb->speed = opt_foreground_rebuild ? 1 << 30 : 50;
     func = storeCossRebuildFromSwapLog;
index 3c91f702f88f90f283a7e6a37a87f9388dd521da..601e00ffb4fcec393f74956cc71df82dd8ebb9af 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_io_coss.cc,v 1.7 2001/01/12 00:37:33 wessels Exp $
+ * $Id: store_io_coss.cc,v 1.8 2001/03/03 10:39:37 hno Exp $
  *
  * DEBUG: section 81    Storage Manager COSS Interface
  * AUTHOR: Eric Stern
@@ -49,6 +49,8 @@ static CossMemBuf *storeCossCreateMemBuf(SwapDir * SD, size_t start,
 static CBDUNL storeCossIOFreeEntry;
 static CBDUNL storeCossMembufFree;
 
+CBDATA_TYPE(storeIOState);
+
 /* === PUBLIC =========================================================== */
 
 /*
@@ -128,7 +130,8 @@ storeCossCreate(SwapDir * SD, StoreEntry * e, STFNCB * file_callback, STIOCB * c
     CossState *cstate;
     storeIOState *sio;
 
-    sio = CBDATA_ALLOC(storeIOState, storeCossIOFreeEntry);
+    CBDATA_INIT_TYPE_FREECB(storeIOState, storeCossIOFreeEntry);
+    sio = cbdataAlloc(storeIOState);
     cstate = memPoolAlloc(coss_state_pool);
     sio->fsstate = cstate;
     sio->offset = 0;
@@ -172,7 +175,8 @@ storeCossOpen(SwapDir * SD, StoreEntry * e, STFNCB * file_callback,
 
     debug(81, 3) ("storeCossOpen: offset %d\n", f);
 
-    sio = CBDATA_ALLOC(storeIOState, storeCossIOFreeEntry);
+    CBDATA_INIT_TYPE_FREECB(storeIOState, storeCossIOFreeEntry);
+    sio = cbdataAlloc(storeIOState);
     cstate = memPoolAlloc(coss_state_pool);
 
     sio->fsstate = cstate;
@@ -477,8 +481,8 @@ storeCossCreateMemBuf(SwapDir * SD, size_t start,
     int numreleased = 0;
     CossInfo *cs = (CossInfo *) SD->fsdata;
 
-    CBDATA_INIT_TYPE(CossMemBuf);
-    newmb = CBDATA_ALLOC(CossMemBuf, storeCossMembufFree);
+    CBDATA_INIT_TYPE_FREECB(CossMemBuf, storeCossMembufFree);
+    newmb = cbdataAlloc(CossMemBuf);
     newmb->diskstart = start;
     debug(81, 3) ("storeCossCreateMemBuf: creating new membuf at %d\n", newmb->diskstart);
     newmb->diskend = newmb->diskstart + COSS_MEMBUF_SZ - 1;
index 22c621be16dca88c7bdc56751bb22560e80cc517..0b93c8c187a947c168405e78ed324e8510309d26 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir_diskd.cc,v 1.44 2001/03/01 22:28:22 hno Exp $
+ * $Id: store_dir_diskd.cc,v 1.45 2001/03/03 10:39:38 hno Exp $
  *
  * DEBUG: section 47    Store Directory Routines
  * AUTHOR: Duane Wessels
@@ -1021,7 +1021,7 @@ storeDiskdDirRebuild(SwapDir * sd)
     FILE *fp;
     EVH *func = NULL;
     CBDATA_INIT_TYPE(RebuildState);
-    rb = CBDATA_ALLOC(RebuildState, NULL);
+    rb = cbdataAlloc(RebuildState);
     rb->sd = sd;
     rb->speed = opt_foreground_rebuild ? 1 << 30 : 50;
     /*
@@ -1706,7 +1706,7 @@ storeDiskdDirStats(SwapDir * SD, StoreEntry * sentry)
     storeAppendPrintf(sentry, "Pending operations: %d\n", diskdinfo->away);
 }
 
-static void 
+static void
 storeDiskdDirParseQ1(SwapDir * sd, const char *name, const char *value, int reconfiguring)
 {
     diskdinfo_t *diskdinfo = sd->fsdata;
@@ -1716,7 +1716,7 @@ storeDiskdDirParseQ1(SwapDir * sd, const char *name, const char *value, int reco
        debug(3, 1) ("cache_dir '%s' new Q1 value '%d'\n", diskdinfo->magic1);
 }
 
-static void 
+static void
 storeDiskdDirParseQ2(SwapDir * sd, const char *name, const char *value, int reconfiguring)
 {
     diskdinfo_t *diskdinfo = sd->fsdata;
index b813adf30763d5145074c8077f5aefb797e9a739..0220aa324286e0c072f09d7734a0990b9362e406 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_io_diskd.cc,v 1.20 2001/01/12 00:37:33 wessels Exp $
+ * $Id: store_io_diskd.cc,v 1.21 2001/03/03 10:39:38 hno Exp $
  *
  * DEBUG: section 81    Squid-side DISKD I/O functions.
  * AUTHOR: Duane Wessels
@@ -46,6 +46,8 @@ static int storeDiskdSend(int, SwapDir *, int, storeIOState *, int, int, int);
 static void storeDiskdIOCallback(storeIOState * sio, int errflag);
 static CBDUNL storeDiskdIOFreeEntry;
 
+CBDATA_TYPE(storeIOState);
+
 /* === PUBLIC =========================================================== */
 
 storeIOState *
@@ -68,7 +70,8 @@ storeDiskdOpen(SwapDir * SD, StoreEntry * e, STFNCB * file_callback,
        diskd_stats.open_fail_queue_len++;
        return NULL;
     }
-    sio = CBDATA_ALLOC(storeIOState, storeDiskdIOFreeEntry);
+    CBDATA_INIT_TYPE_FREECB(storeIOState, storeDiskdIOFreeEntry);
+    sio = cbdataAlloc(storeIOState);
     sio->fsstate = diskdstate = memPoolAlloc(diskd_state_pool);
 
     sio->swap_filen = f;
@@ -126,7 +129,8 @@ storeDiskdCreate(SwapDir * SD, StoreEntry * e, STFNCB * file_callback,
     f = storeDiskdDirMapBitAllocate(SD);
     debug(81, 3) ("storeDiskdCreate: fileno %08X\n", f);
 
-    sio = CBDATA_ALLOC(storeIOState, storeDiskdIOFreeEntry);
+    CBDATA_INIT_TYPE_FREECB(storeIOState, storeDiskdIOFreeEntry);
+    sio = cbdataAlloc(storeIOState);
     sio->fsstate = diskdstate = memPoolAlloc(diskd_state_pool);
 
     sio->swap_filen = f;
index 0d5f8037a274c8892bbffc392a85e85726680991..f9abeeda63358640ad331ba6fd3738ff3a006e93 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir_ufs.cc,v 1.30 2001/02/19 23:10:07 hno Exp $
+ * $Id: store_dir_ufs.cc,v 1.31 2001/03/03 10:39:39 hno Exp $
  *
  * DEBUG: section 47    Store Directory Routines
  * AUTHOR: Duane Wessels
@@ -825,7 +825,7 @@ storeUfsDirRebuild(SwapDir * sd)
     FILE *fp;
     EVH *func = NULL;
     CBDATA_INIT_TYPE(RebuildState);
-    rb = CBDATA_ALLOC(RebuildState, NULL);
+    rb = cbdataAlloc(RebuildState);
     rb->sd = sd;
     rb->speed = opt_foreground_rebuild ? 1 << 30 : 50;
     /*
index 212b06c0b28b47970264706108f525d03156b70c..9734d3b540f93d163cfe1f52f5283f95043442cf 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_io_ufs.cc,v 1.6 2001/01/12 00:37:35 wessels Exp $
+ * $Id: store_io_ufs.cc,v 1.7 2001/03/03 10:39:39 hno Exp $
  *
  * DEBUG: section 79    Storage Manager UFS Interface
  * AUTHOR: Duane Wessels
@@ -42,6 +42,8 @@ static DWCB storeUfsWriteDone;
 static void storeUfsIOCallback(storeIOState * sio, int errflag);
 static CBDUNL storeUfsIOFreeEntry;
 
+CBDATA_TYPE(storeIOState);
+
 /* === PUBLIC =========================================================== */
 
 storeIOState *
@@ -60,7 +62,8 @@ storeUfsOpen(SwapDir * SD, StoreEntry * e, STFNCB * file_callback,
        return NULL;
     }
     debug(79, 3) ("storeUfsOpen: opened FD %d\n", fd);
-    sio = CBDATA_ALLOC(storeIOState, storeUfsIOFreeEntry);
+    CBDATA_INIT_TYPE_FREECB(storeIOState, storeUfsIOFreeEntry);
+    sio = cbdataAlloc(storeIOState);
     sio->fsstate = memPoolAlloc(ufs_state_pool);
 
     sio->swap_filen = f;
@@ -107,7 +110,8 @@ storeUfsCreate(SwapDir * SD, StoreEntry * e, STFNCB * file_callback, STIOCB * ca
        return NULL;
     }
     debug(79, 3) ("storeUfsCreate: opened FD %d\n", fd);
-    sio = CBDATA_ALLOC(storeIOState, storeUfsIOFreeEntry);
+    CBDATA_INIT_TYPE_FREECB(storeIOState, storeUfsIOFreeEntry);
+    sio = cbdataAlloc(storeIOState);
     sio->fsstate = memPoolAlloc(ufs_state_pool);
 
     sio->swap_filen = filn;
index bf5bf2530fb53a483f70dfff38361cd5746ca0d8..60717dc3786bac4761c42c69eb3cb019e4c0be7f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ftp.cc,v 1.307 2001/01/12 00:37:17 wessels Exp $
+ * $Id: ftp.cc,v 1.308 2001/03/03 10:39:32 hno Exp $
  *
  * DEBUG: section 9     File Transfer Protocol (FTP)
  * AUTHOR: Harvest Derived
@@ -1047,7 +1047,7 @@ ftpStart(FwdState * fwd)
     HttpReply *reply;
 
     CBDATA_INIT_TYPE(FtpStateData);
-    ftpState = CBDATA_ALLOC(FtpStateData, NULL);
+    ftpState = cbdataAlloc(FtpStateData);
     debug(9, 3) ("ftpStart: '%s'\n", url);
     statCounter.server.all.requests++;
     statCounter.server.ftp.requests++;
index 0d33917719edce4ccbfbdf1c00843ac109d788ff..76d3c8f6f52c6e12f85bba1d4fcc53f192b41b0e 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: gopher.cc,v 1.159 2001/01/12 00:37:18 wessels Exp $
+ * $Id: gopher.cc,v 1.160 2001/03/03 10:39:32 hno Exp $
  *
  * DEBUG: section 10    Gopher
  * AUTHOR: Harvest Derived
@@ -818,7 +818,7 @@ CreateGopherStateData(void)
 {
     GopherStateData *gd;
     CBDATA_INIT_TYPE(GopherStateData);
-    gd = CBDATA_ALLOC(GopherStateData, NULL);
+    gd = cbdataAlloc(GopherStateData);
     gd->buf = memAllocate(MEM_4K_BUF);
     return (gd);
 }
index 97aea6701296309b3c758b6edcc99d5f42c9c214..ccb5528a15f6b6b5f68a3674163639a9bad05e78 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: helper.cc,v 1.25 2001/01/31 22:16:38 hno Exp $
+ * $Id: helper.cc,v 1.26 2001/03/03 10:39:32 hno Exp $
  *
  * DEBUG: section 29    Helper process maintenance
  * AUTHOR: Harvest Derived?
@@ -103,7 +103,7 @@ helperOpenServers(helper * hlp)
            continue;
        }
        hlp->n_running++;
-       srv = CBDATA_ALLOC(helper_server, NULL);
+       srv = cbdataAlloc(helper_server);
        srv->flags.alive = 1;
        srv->index = k;
        srv->rfd = rfd;
@@ -179,7 +179,7 @@ helperStatefulOpenServers(statefulhelper * hlp)
            continue;
        }
        hlp->n_running++;
-       srv = CBDATA_ALLOC(helper_stateful_server, NULL);
+       srv = cbdataAlloc(helper_stateful_server);
        srv->flags.alive = 1;
        srv->flags.reserved = S_HELPER_FREE;
        srv->deferred_requests = 0;
@@ -537,7 +537,7 @@ helper *
 helperCreate(const char *name)
 {
     helper *hlp;
-    hlp = CBDATA_ALLOC(helper, NULL);
+    hlp = cbdataAlloc(helper);
     hlp->id_name = name;
     return hlp;
 }
@@ -546,7 +546,7 @@ statefulhelper *
 helperStatefulCreate(const char *name)
 {
     statefulhelper *hlp;
-    hlp = CBDATA_ALLOC(statefulhelper, NULL);
+    hlp = cbdataAlloc(statefulhelper);
     hlp->id_name = name;
     return hlp;
 }
index 93eb5730ff84ebe857085656ff0c11cf6d98dd5f..ae0dabaecea1e0a0d6497fc18381e00493584881 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: http.cc,v 1.377 2001/01/12 00:37:18 wessels Exp $
+ * $Id: http.cc,v 1.378 2001/03/03 10:39:32 hno Exp $
  *
  * DEBUG: section 11    Hypertext Transfer Protocol (HTTP)
  * AUTHOR: Harvest Derived
@@ -928,7 +928,7 @@ httpStart(FwdState * fwd)
     debug(11, 3) ("httpStart: \"%s %s\"\n",
        RequestMethodStr[orig_req->method],
        storeUrl(fwd->entry));
-    httpState = CBDATA_ALLOC(HttpStateData, NULL);
+    httpState = cbdataAlloc(HttpStateData);
     storeLockObject(fwd->entry);
     httpState->fwd = fwd;
     httpState->entry = fwd->entry;
index 63b143baedb6328df36b14249cf78d40b078dc0d..ca4e335e827fa6f4346ca45ce36116dc282afe3f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ident.cc,v 1.56 2001/01/12 00:37:18 wessels Exp $
+ * $Id: ident.cc,v 1.57 2001/03/03 10:39:32 hno Exp $
  *
  * DEBUG: section 30    Ident (RFC 931)
  * AUTHOR: Duane Wessels
@@ -216,7 +216,7 @@ identStart(struct sockaddr_in *me, struct sockaddr_in *my_peer, IDCB * callback,
        return;
     }
     CBDATA_INIT_TYPE(IdentStateData);
-    state = CBDATA_ALLOC(IdentStateData, NULL);
+    state = cbdataAlloc(IdentStateData);
     state->hash.key = xstrdup(key);
     state->fd = fd;
     state->me = *me;
index b7cd66ed9d8b2b3149a99e60eb8585645946ce25..b7dca00b5442f794c20d75c1f87bf80912b17e54 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ipcache.cc,v 1.233 2001/02/23 20:59:51 hno Exp $
+ * $Id: ipcache.cc,v 1.234 2001/03/03 10:39:32 hno Exp $
  *
  * DEBUG: section 14    IP Cache
  * AUTHOR: Harvest Derived
@@ -432,7 +432,7 @@ ipcache_nbgethostbyname(const char *name, IPH * handler, void *handlerData)
     i->handlerData = handlerData;
     cbdataLock(handlerData);
     i->request_time = current_time;
-    c = CBDATA_ALLOC(generic_cbdata, NULL);
+    c = cbdataAlloc(generic_cbdata);
     c->data = i;
 #if USE_DNSSERVERS
     dnsSubmit(hashKeyStr(&i->hash), ipcacheHandleReply, c);
index 5f32d7bbf127134899e7ed1fa4b6c3d7f2d4a4db..a134a3adf98d5a0e00f0c79f994f243637c4421b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: neighbors.cc,v 1.292 2001/01/12 00:37:19 wessels Exp $
+ * $Id: neighbors.cc,v 1.293 2001/03/03 10:39:33 hno Exp $
  *
  * DEBUG: section 15    Neighbor Routines
  * AUTHOR: Harvest Derived
@@ -1123,7 +1123,7 @@ peerCountMcastPeersStart(void *data)
     p->mcast.flags.count_event_pending = 0;
     snprintf(url, MAX_URL, "http://%s/", inet_ntoa(p->in_addr.sin_addr));
     fake = storeCreateEntry(url, url, null_request_flags, METHOD_GET);
-    psstate = CBDATA_ALLOC(ps_state, NULL);
+    psstate = cbdataAlloc(ps_state);
     psstate->request = requestLink(urlParse(METHOD_GET, url));
     psstate->entry = fake;
     psstate->callback = NULL;
index acfa1b5ef70b10dd10e307ff0aa92e0d9649aabf..1a36a3142061cffd840ccc7e55dda92c9c333b4c 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: net_db.cc,v 1.156 2001/01/12 00:37:20 wessels Exp $
+ * $Id: net_db.cc,v 1.157 2001/03/03 10:39:33 hno Exp $
  *
  * DEBUG: section 38    Network Measurement Database
  * AUTHOR: Duane Wessels
@@ -682,7 +682,7 @@ netdbPingSite(const char *hostname)
     if ((n = netdbLookupHost(hostname)) != NULL)
        if (n->next_ping_time > squid_curtime)
            return;
-    h = CBDATA_ALLOC(generic_cbdata, NULL);
+    h = cbdataAlloc(generic_cbdata);
     h->data = xstrdup(hostname);
     ipcache_nbgethostbyname(hostname, netdbSendPing, h);
 #endif
@@ -991,7 +991,7 @@ netdbExchangeStart(void *data)
     char *uri;
     netdbExchangeState *ex;
     CBDATA_INIT_TYPE(netdbExchangeState);
-    ex = CBDATA_ALLOC(netdbExchangeState, NULL);
+    ex = cbdataAlloc(netdbExchangeState);
     cbdataLock(p);
     ex->p = p;
     uri = internalRemoteUri(p->host, p->http_port, "/squid-internal-dynamic/", "netdb");
index aad9bbea76a9738ecce907f4b43e6a7dc54ecb7e..033e62c2e94e4635662e4531a47c6559933bec20 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: peer_digest.cc,v 1.78 2001/02/07 18:56:52 hno Exp $
+ * $Id: peer_digest.cc,v 1.79 2001/03/03 10:39:33 hno Exp $
  *
  * DEBUG: section 72    Peer Digest Routines
  * AUTHOR: Alex Rousskov
@@ -107,7 +107,7 @@ peerDigestCreate(peer * p)
     assert(p);
 
     CBDATA_INIT_TYPE(PeerDigest);
-    pd = CBDATA_ALLOC(PeerDigest, NULL);
+    pd = cbdataAlloc(PeerDigest);
     peerDigestInit(pd, p);
     cbdataLock(pd->peer);      /* we will use the peer */
 
@@ -295,7 +295,7 @@ peerDigestRequest(PeerDigest * pd)
     if (p->login)
        xstrncpy(req->login, p->login, MAX_LOGIN_SZ);
     /* create fetch state structure */
-    fetch = CBDATA_ALLOC(DigestFetchState, NULL);
+    fetch = cbdataAlloc(DigestFetchState);
     fetch->request = requestLink(req);
     fetch->pd = pd;
     fetch->offset = 0;
index 91687ce6d91535d80bbc7b43b957a7a1db3fbd95..97afc178d829ea361b89d340b5d1bf73bcaa439c 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: peer_select.cc,v 1.113 2001/02/07 18:56:52 hno Exp $
+ * $Id: peer_select.cc,v 1.114 2001/03/03 10:39:33 hno Exp $
  *
  * DEBUG: section 44    Peer Selection Algorithm
  * AUTHOR: Duane Wessels
@@ -139,7 +139,7 @@ peerSelect(request_t * request,
        debug(44, 3) ("peerSelect: %s\n", storeUrl(entry));
     else
        debug(44, 3) ("peerSelect: %s\n", RequestMethodStr[request->method]);
-    psstate = CBDATA_ALLOC(ps_state, NULL);
+    psstate = cbdataAlloc(ps_state);
     psstate->request = requestLink(request);
     psstate->entry = entry;
     psstate->callback = callback;
index 117f8d584b502250d6fe60229a0c75da37bbf522..8066b44dc666ce6b0ea14c777337c711a7e459a0 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: protos.h,v 1.399 2001/02/23 20:59:51 hno Exp $
+ * $Id: protos.h,v 1.400 2001/03/03 10:39:33 hno Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -101,20 +101,20 @@ extern void parse_cachedir_options(SwapDir * sd, struct cache_dir_option *option
  */
 extern void cbdataInit(void);
 #if CBDATA_DEBUG
-extern void *cbdataInternalAllocDbg(cbdata_type type, CBDUNL *, int, const char *);
+extern void *cbdataInternalAllocDbg(cbdata_type type, int, const char *);
 extern void cbdataLockDbg(const void *p, const char *, int);
 extern void cbdataUnlockDbg(const void *p, const char *, int);
 #else
-extern void *cbdataInternalAlloc(cbdata_type type, CBDUNL *);
+extern void *cbdataInternalAlloc(cbdata_type type);
 extern void cbdataLock(const void *p);
 extern void cbdataUnlock(const void *p);
 #endif
-/* Note: Allocations is done using the CBDATA_ALLOC macro */
-
-extern void cbdataFree(void *p);
+/* Note: Allocations is done using the cbdataAlloc macro */
+extern void cbdataInternalFree(void *p);
 extern int cbdataValid(const void *p);
-extern void cbdataInitType(cbdata_type type, char *label, int size);
-extern cbdata_type cbdataAddType(cbdata_type type, char *label, int size);
+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);
+extern int cbdataLocked(const void *p);
 
 extern void clientdbInit(void);
 extern void clientdbUpdate(struct in_addr, log_type, protocol_t, size_t);
index d2ffb072a2f2948874a1fc644ae7ccaca9105dba..60f11c50edd191a0e2fa21265f127fd6028436a6 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: redirect.cc,v 1.87 2001/01/12 00:37:20 wessels Exp $
+ * $Id: redirect.cc,v 1.88 2001/03/03 10:39:33 hno Exp $
  *
  * DEBUG: section 29    Redirector
  * AUTHOR: Duane Wessels
@@ -123,7 +123,7 @@ redirectStart(clientHttpRequest * http, RH * handler, void *data)
        handler(data, NULL);
        return;
     }
-    r = CBDATA_ALLOC(redirectStateData, NULL);
+    r = cbdataAlloc(redirectStateData);
     r->orig_url = xstrdup(http->uri);
     r->client_addr = conn->log_addr;
     if (http->request->auth_user_request)
index fb3413531dac4ccbf3b1e6b31cdeff8f66868703..75e4d8588bdc90750b105d5c5f3265f77b44f587 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_repl_heap.cc,v 1.5 2001/02/07 18:56:56 hno Exp $
+ * $Id: store_repl_heap.cc,v 1.6 2001/03/03 10:39:39 hno Exp $
  *
  * DEBUG: section ?     HEAP based removal policies
  * AUTHOR: Henrik Nordstrom
@@ -151,7 +151,7 @@ heap_walkInit(RemovalPolicy * policy)
     RemovalPolicyWalker *walker;
     HeapWalkData *heap_walk;
     heap->nwalkers += 1;
-    walker = CBDATA_ALLOC(RemovalPolicyWalker, NULL);
+    walker = cbdataAlloc(RemovalPolicyWalker);
     heap_walk = xcalloc(1, sizeof(*heap_walk));
     heap_walk->current = 0;
     walker->_policy = policy;
@@ -224,7 +224,7 @@ heap_purgeInit(RemovalPolicy * policy, int max_scan)
     RemovalPurgeWalker *walker;
     HeapPurgeData *heap_walk;
     heap->nwalkers += 1;
-    walker = CBDATA_ALLOC(RemovalPurgeWalker, NULL);
+    walker = cbdataAlloc(RemovalPurgeWalker);
     heap_walk = xcalloc(1, sizeof(*heap_walk));
     heap_walk->min_age = 0.0;
     heap_walk->locked_entries = NULL;
@@ -262,7 +262,7 @@ createRemovalPolicy_heap(wordlist * args)
     HeapPolicyData *heap_data;
     char *keytype;
     /* Allocate the needed structures */
-    policy = CBDATA_ALLOC(RemovalPolicy, NULL);
+    policy = cbdataAlloc(RemovalPolicy);
     heap_data = xcalloc(1, sizeof(*heap_data));
     /* Initialize the policy data */
     heap_data->policy = policy;
index 9b963cb9cc1c3172e09afdf50fb9f1833356095a..851e13bae0cead41ba0462f92d66ec3325b8cd63 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_repl_lru.cc,v 1.7 2001/02/07 18:56:56 hno Exp $
+ * $Id: store_repl_lru.cc,v 1.8 2001/03/03 10:39:39 hno Exp $
  *
  * DEBUG: section ?     LRU Removal policy
  * AUTHOR: Henrik Nordstrom
@@ -162,7 +162,7 @@ lru_walkInit(RemovalPolicy * policy)
     RemovalPolicyWalker *walker;
     LruWalkData *lru_walk;
     lru->nwalkers += 1;
-    walker = CBDATA_ALLOC(RemovalPolicyWalker, NULL);
+    walker = cbdataAlloc(RemovalPolicyWalker);
     lru_walk = xcalloc(1, sizeof(*lru_walk));
     walker->_policy = policy;
     walker->_data = lru_walk;
@@ -231,7 +231,7 @@ lru_purgeInit(RemovalPolicy * policy, int max_scan)
     RemovalPurgeWalker *walker;
     LruPurgeData *lru_walk;
     lru->nwalkers += 1;
-    walker = CBDATA_ALLOC(RemovalPurgeWalker, NULL);
+    walker = cbdataAlloc(RemovalPurgeWalker);
     lru_walk = xcalloc(1, sizeof(*lru_walk));
     walker->_policy = policy;
     walker->_data = lru_walk;
@@ -268,7 +268,7 @@ createRemovalPolicy_lru(wordlist * args)
        lru_node_pool = memPoolCreate("LRU policy node", sizeof(LruNode));
     /* Allocate the needed structures */
     lru_data = xcalloc(1, sizeof(*lru_data));
-    policy = CBDATA_ALLOC(RemovalPolicy, NULL);
+    policy = cbdataAlloc(RemovalPolicy);
     /* Initialize the URL data */
     lru_data->policy = policy;
     /* Populate the policy structure */
index 93f65a943c2c435facb5de98981c4a670dadeeb4..8c155f0834129ebe7311d5b969e7c3c51211c034 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ssl.cc,v 1.111 2001/01/12 00:37:21 wessels Exp $
+ * $Id: ssl.cc,v 1.112 2001/03/03 10:39:33 hno Exp $
  *
  * DEBUG: section 26    Secure Sockets Layer Proxy
  * AUTHOR: Duane Wessels
@@ -484,7 +484,7 @@ sslStart(int fd, const char *url, request_t * request, size_t * size_ptr, int *s
        return;
     }
     CBDATA_INIT_TYPE(SslStateData);
-    sslState = CBDATA_ALLOC(SslStateData, NULL);
+    sslState = cbdataAlloc(SslStateData);
 #if DELAY_POOLS
     sslState->delay_id = delayClient(request);
     delayRegisterDelayIdPtr(&sslState->delay_id);
index ab0072a4b71f964fba8a17b23ec785b24eaa8da8..33041914aebe8d37fb05ef230c06f7d56f1501dd 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: stat.cc,v 1.344 2001/02/07 18:56:52 hno Exp $
+ * $Id: stat.cc,v 1.345 2001/03/03 10:39:33 hno Exp $
  *
  * DEBUG: section 18    Cache Manager Statistics
  * AUTHOR: Harvest Derived
@@ -345,7 +345,7 @@ static void
 statObjectsStart(StoreEntry * sentry, STOBJFLT * filter)
 {
     StatObjectsState *state;
-    state = CBDATA_ALLOC(StatObjectsState, NULL);
+    state = cbdataAlloc(StatObjectsState);
     state->sentry = sentry;
     state->filter = filter;
     storeLockObject(sentry);
index 5e6e99875251f80db74d8b1934cf340115653f52..006426ae752462de59d4536ece65e6aebd34a235 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_client.cc,v 1.100 2001/01/12 00:37:22 wessels Exp $
+ * $Id: store_client.cc,v 1.101 2001/03/03 10:39:34 hno Exp $
  *
  * DEBUG: section 20    Storage Manager Client-Side Interface
  * AUTHOR: Duane Wessels
@@ -133,7 +133,7 @@ storeClientListAdd(StoreEntry * e, void *data)
 #endif
     e->refcount++;
     mem->nclients++;
-    sc = CBDATA_ALLOC(store_client, NULL);
+    sc = cbdataAlloc(store_client);
     cbdataLock(data);          /* locked while we point to it */
     sc->callback_data = data;
     sc->seen_offset = 0;
index 4a7c773805c0368a1a55ce71a652cdde4e1361b7..393bdf4b835053ab10c15ac5963193e2ae6a475b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_digest.cc,v 1.48 2001/02/07 19:09:25 hno Exp $
+ * $Id: store_digest.cc,v 1.49 2001/03/03 10:39:34 hno Exp $
  *
  * DEBUG: section 71    Store Digest Manager
  * AUTHOR: Alex Rousskov
@@ -352,7 +352,7 @@ storeDigestRewriteStart(void *datanotused)
     flags.cachable = 1;
     e = storeCreateEntry(url, url, flags, METHOD_GET);
     assert(e);
-    sd_state.rewrite_lock = CBDATA_ALLOC(generic_cbdata, NULL);
+    sd_state.rewrite_lock = cbdataAlloc(generic_cbdata);
     sd_state.rewrite_lock->data = e;
     debug(71, 3) ("storeDigestRewrite: url: %s key: %s\n", url, storeKeyText(e->hash.key));
     e->mem_obj->request = requestLink(urlParse(METHOD_GET, url));
index dc02fc7533981e724f3b9f21e95d85490ecf3313..18698ff0fbdc62f498bde462203dbb7589378958 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_swapout.cc,v 1.79 2001/01/12 00:37:22 wessels Exp $
+ * $Id: store_swapout.cc,v 1.80 2001/03/03 10:39:34 hno Exp $
  *
  * DEBUG: section 20    Storage Manager Swapout Functions
  * AUTHOR: Duane Wessels
@@ -61,7 +61,7 @@ storeSwapOutStart(StoreEntry * e)
     storeSwapTLVFree(tlv_list);
     mem->swap_hdr_sz = (size_t) swap_hdr_sz;
     /* Create the swap file */
-    c = CBDATA_ALLOC(generic_cbdata, NULL);
+    c = cbdataAlloc(generic_cbdata);
     c->data = e;
     mem->swapout.sio = storeCreate(e, storeSwapOutFileNotify, storeSwapOutFileClosed, c);
     if (NULL == mem->swapout.sio) {
index 6a38383ee52321722c363fdd25f09cd4a9a68439..54e54c54117a4f4632a5348693cdaaeaa6a5e6d2 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: tunnel.cc,v 1.111 2001/01/12 00:37:21 wessels Exp $
+ * $Id: tunnel.cc,v 1.112 2001/03/03 10:39:33 hno Exp $
  *
  * DEBUG: section 26    Secure Sockets Layer Proxy
  * AUTHOR: Duane Wessels
@@ -484,7 +484,7 @@ sslStart(int fd, const char *url, request_t * request, size_t * size_ptr, int *s
        return;
     }
     CBDATA_INIT_TYPE(SslStateData);
-    sslState = CBDATA_ALLOC(SslStateData, NULL);
+    sslState = cbdataAlloc(SslStateData);
 #if DELAY_POOLS
     sslState->delay_id = delayClient(request);
     delayRegisterDelayIdPtr(&sslState->delay_id);
index cee72c10d7a99a1b93fd06852c5d3853a6fb9db3..28a5cbf947100ecaf182f3504bde4378b3d0b8cf 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: urn.cc,v 1.66 2001/02/23 20:59:51 hno Exp $
+ * $Id: urn.cc,v 1.67 2001/03/03 10:39:34 hno Exp $
  *
  * DEBUG: section 52    URN Parsing
  * AUTHOR: Kostas Anagnostakis
@@ -108,7 +108,7 @@ urnStart(request_t * r, StoreEntry * e)
     ErrorState *err;
     debug(52, 3) ("urnStart: '%s'\n", storeUrl(e));
     CBDATA_INIT_TYPE(UrnState);
-    urnState = CBDATA_ALLOC(UrnState, NULL);
+    urnState = cbdataAlloc(UrnState);
     urnState->entry = e;
     urnState->request = requestLink(r);
     storeLockObject(urnState->entry);
index 4369c3fb6e21e7f7693aee186996515913f1894e..c3b429a825f9a60f061aae11742f02e2246998ef 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: wais.cc,v 1.135 2001/01/12 00:37:23 wessels Exp $
+ * $Id: wais.cc,v 1.136 2001/03/03 10:39:34 hno Exp $
  *
  * DEBUG: section 24    WAIS Relay
  * AUTHOR: Harvest Derived
@@ -230,7 +230,7 @@ waisStart(FwdState * fwd)
     statCounter.server.all.requests++;
     statCounter.server.other.requests++;
     CBDATA_INIT_TYPE(WaisStateData);
-    waisState = CBDATA_ALLOC(WaisStateData, NULL);
+    waisState = cbdataAlloc(WaisStateData);
     waisState->method = method;
     waisState->request_hdr = &request->header;
     waisState->fd = fd;
index e6bf2ffddd25339776c708e94a068bd4b585aa68..9797c627b9118e0687679151e2a8f92339cf3fac 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: whois.cc,v 1.14 2001/01/12 00:37:23 wessels Exp $
+ * $Id: whois.cc,v 1.15 2001/03/03 10:39:34 hno Exp $
  *
  * DEBUG: section 75    WHOIS protocol
  * AUTHOR: Duane Wessels, Kostas Anagnostakis
@@ -59,7 +59,7 @@ whoisStart(FwdState * fwd)
     char *buf;
     size_t l;
     CBDATA_INIT_TYPE(WhoisState);
-    p = CBDATA_ALLOC(WhoisState, NULL);
+    p = cbdataAlloc(WhoisState);
     p->request = fwd->request;
     p->entry = fwd->entry;
     p->fwd = fwd;