This patch is generated from the cbdata-20010303 branch of HEAD-20010303 in squid Tue Sep 9 11:51:08 2003 GMT See http://devel.squid-cache.org/ Index: squid/doc/Programming-Guide/prog-guide.sgml diff -u squid/doc/Programming-Guide/prog-guide.sgml:1.9 squid/doc/Programming-Guide/prog-guide.sgml:1.9.10.1 --- squid/doc/Programming-Guide/prog-guide.sgml:1.9 Wed Jan 31 14:20:26 2001 +++ squid/doc/Programming-Guide/prog-guide.sgml Sat Feb 24 03:15:22 2001 @@ -2411,7 +2411,7 @@ 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 @@ With this scheme, nothing bad happens if - callback_data = CBDATA_ALLOC(...); + callback_data = cbdataAlloc(...); ... cbdataLock(callback_data); fooOperationStart(bar, callback_func, callback_data); @@ -2449,7 +2449,7 @@

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. @@ -2463,6 +2463,8 @@ * (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);

@@ -2475,10 +2477,6 @@ extern CBDATA_GLOBAL_TYPE(type_of_data); /* CBDATA_UNDEF */ - -

- TODO: Restructure the free function so there is one free function - associated with the whole cbdata type rather than per allocation. Cache Manager Index: squid/src/acl.c diff -u squid/src/acl.c:1.23 squid/src/acl.c:1.23.2.1 --- squid/src/acl.c:1.23 Fri Feb 23 13:03:30 2001 +++ squid/src/acl.c Sat Feb 24 03:11:26 2001 @@ -967,7 +967,7 @@ 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 @@ { 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: squid/src/asn.c diff -u squid/src/asn.c:1.9 squid/src/asn.c:1.9.10.1 --- squid/src/asn.c:1.9 Wed Feb 7 11:11:48 2001 +++ squid/src/asn.c Sat Feb 24 03:11:26 2001 @@ -187,7 +187,7 @@ 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: squid/src/cache_cf.c diff -u squid/src/cache_cf.c:1.20 squid/src/cache_cf.c:1.20.2.2 --- squid/src/cache_cf.c:1.20 Fri Feb 23 13:03:30 2001 +++ squid/src/cache_cf.c Sat Mar 3 02:23:32 2001 @@ -380,7 +380,7 @@ 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 @@ 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 @@ 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 @@ 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: squid/src/cbdata.c diff -u squid/src/cbdata.c:1.9 squid/src/cbdata.c:1.9.10.3 --- squid/src/cbdata.c:1.9 Wed Jan 31 13:47:16 2001 +++ squid/src/cbdata.c Sat Mar 3 02:23:32 2001 @@ -71,8 +71,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ } 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 @@ } 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 @@ #endif { cbdata *c; + FREE *free_func; if (p == NULL) return; c = (cbdata *) (((char *) p) - OFFSET_OF(cbdata, data)); @@ -239,9 +257,10 @@ 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: squid/src/client_side.c diff -u squid/src/client_side.c:1.22 squid/src/client_side.c:1.21.2.2 --- squid/src/client_side.c:1.22 Fri Mar 2 01:13:48 2001 +++ squid/src/client_side.c Sat Mar 3 02:19:51 2001 @@ -2302,7 +2302,7 @@ 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 @@ 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 @@ 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: squid/src/comm.c diff -u squid/src/comm.c:1.8 squid/src/comm.c:1.8.2.1 --- squid/src/comm.c:1.8 Fri Feb 23 11:48:58 2001 +++ squid/src/comm.c Sat Feb 24 03:11:27 2001 @@ -232,7 +232,7 @@ { 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: squid/src/defines.h diff -u squid/src/defines.h:1.8 squid/src/defines.h:1.8.14.1 --- squid/src/defines.h:1.8 Fri Jan 12 00:20:32 2001 +++ squid/src/defines.h Sat Feb 24 03:11:27 2001 @@ -281,10 +281,12 @@ #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: squid/src/enums.h diff -u squid/src/enums.h:1.16 squid/src/enums.h:1.16.2.1 --- squid/src/enums.h:1.16 Sun Feb 18 03:18:47 2001 +++ squid/src/enums.h Sat Feb 24 03:11:27 2001 @@ -753,6 +753,5 @@ CBDATA_RemovalPolicyWalker, CBDATA_RemovalPurgeWalker, CBDATA_store_client, - CBDATA_storeIOState, CBDATA_FIRST_CUSTOM_TYPE = 1000 } cbdata_type; Index: squid/src/errorpage.c diff -u squid/src/errorpage.c:1.10 squid/src/errorpage.c:1.10.14.1 --- squid/src/errorpage.c:1.10 Fri Jan 12 00:20:32 2001 +++ squid/src/errorpage.c Sat Feb 24 03:11:28 2001 @@ -235,7 +235,7 @@ 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: squid/src/forward.c diff -u squid/src/forward.c:1.9 squid/src/forward.c:1.9.14.1 --- squid/src/forward.c:1.9 Fri Jan 12 00:20:32 2001 +++ squid/src/forward.c Sat Feb 24 03:11:28 2001 @@ -544,7 +544,7 @@ default: break; } - fwdState = CBDATA_ALLOC(FwdState, NULL); + fwdState = cbdataAlloc(FwdState); fwdState->entry = e; fwdState->client_fd = fd; fwdState->server_fd = -1; Index: squid/src/fqdncache.c diff -u squid/src/fqdncache.c:1.13 squid/src/fqdncache.c:1.13.2.1 --- squid/src/fqdncache.c:1.13 Fri Feb 23 13:03:30 2001 +++ squid/src/fqdncache.c Sat Feb 24 03:11:28 2001 @@ -387,7 +387,7 @@ 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: squid/src/ftp.c diff -u squid/src/ftp.c:1.11 squid/src/ftp.c:1.11.14.1 --- squid/src/ftp.c:1.11 Fri Jan 12 00:20:33 2001 +++ squid/src/ftp.c Sat Feb 24 03:11:28 2001 @@ -1047,7 +1047,7 @@ 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: squid/src/gopher.c diff -u squid/src/gopher.c:1.7 squid/src/gopher.c:1.7.14.1 --- squid/src/gopher.c:1.7 Fri Jan 12 00:20:33 2001 +++ squid/src/gopher.c Sat Feb 24 03:11:28 2001 @@ -818,7 +818,7 @@ { GopherStateData *gd; CBDATA_INIT_TYPE(GopherStateData); - gd = CBDATA_ALLOC(GopherStateData, NULL); + gd = cbdataAlloc(GopherStateData); gd->buf = memAllocate(MEM_4K_BUF); return (gd); } Index: squid/src/helper.c diff -u squid/src/helper.c:1.8 squid/src/helper.c:1.8.10.1 --- squid/src/helper.c:1.8 Wed Jan 31 14:20:27 2001 +++ squid/src/helper.c Sat Feb 24 03:11:28 2001 @@ -103,7 +103,7 @@ 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 @@ 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 @@ helperCreate(const char *name) { helper *hlp; - hlp = CBDATA_ALLOC(helper, NULL); + hlp = cbdataAlloc(helper); hlp->id_name = name; return hlp; } @@ -546,7 +546,7 @@ helperStatefulCreate(const char *name) { statefulhelper *hlp; - hlp = CBDATA_ALLOC(statefulhelper, NULL); + hlp = cbdataAlloc(statefulhelper); hlp->id_name = name; return hlp; } Index: squid/src/http.c diff -u squid/src/http.c:1.11 squid/src/http.c:1.11.14.1 --- squid/src/http.c:1.11 Fri Jan 12 00:20:33 2001 +++ squid/src/http.c Sat Feb 24 03:11:28 2001 @@ -928,7 +928,7 @@ 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: squid/src/ident.c diff -u squid/src/ident.c:1.6 squid/src/ident.c:1.6.14.1 --- squid/src/ident.c:1.6 Fri Jan 12 00:20:33 2001 +++ squid/src/ident.c Sat Feb 24 03:11:28 2001 @@ -216,7 +216,7 @@ 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: squid/src/ipcache.c diff -u squid/src/ipcache.c:1.14 squid/src/ipcache.c:1.14.2.1 --- squid/src/ipcache.c:1.14 Fri Feb 23 13:03:31 2001 +++ squid/src/ipcache.c Sat Feb 24 03:11:28 2001 @@ -432,7 +432,7 @@ 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: squid/src/neighbors.c diff -u squid/src/neighbors.c:1.8 squid/src/neighbors.c:1.8.14.1 --- squid/src/neighbors.c:1.8 Fri Jan 12 00:20:33 2001 +++ squid/src/neighbors.c Sat Feb 24 03:11:29 2001 @@ -1123,7 +1123,7 @@ 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: squid/src/net_db.c diff -u squid/src/net_db.c:1.9 squid/src/net_db.c:1.9.14.1 --- squid/src/net_db.c:1.9 Fri Jan 12 00:20:33 2001 +++ squid/src/net_db.c Sat Feb 24 03:11:29 2001 @@ -682,7 +682,7 @@ 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 @@ 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: squid/src/peer_digest.c diff -u squid/src/peer_digest.c:1.6 squid/src/peer_digest.c:1.6.10.1 --- squid/src/peer_digest.c:1.6 Wed Feb 7 11:11:48 2001 +++ squid/src/peer_digest.c Sat Feb 24 03:11:29 2001 @@ -107,7 +107,7 @@ 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 @@ 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: squid/src/peer_select.c diff -u squid/src/peer_select.c:1.7 squid/src/peer_select.c:1.7.10.1 --- squid/src/peer_select.c:1.7 Wed Feb 7 11:11:48 2001 +++ squid/src/peer_select.c Sat Feb 24 03:11:29 2001 @@ -139,7 +139,7 @@ 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: squid/src/protos.h diff -u squid/src/protos.h:1.19 squid/src/protos.h:1.19.2.3 --- squid/src/protos.h:1.19 Fri Feb 23 13:03:31 2001 +++ squid/src/protos.h Sat Mar 3 02:23:32 2001 @@ -101,20 +101,20 @@ */ 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: squid/src/redirect.c diff -u squid/src/redirect.c:1.6 squid/src/redirect.c:1.6.14.1 --- squid/src/redirect.c:1.6 Fri Jan 12 00:20:33 2001 +++ squid/src/redirect.c Sat Feb 24 03:11:29 2001 @@ -123,7 +123,7 @@ 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: squid/src/ssl.c diff -u squid/src/ssl.c:1.6 squid/src/ssl.c:1.6.14.1 --- squid/src/ssl.c:1.6 Fri Jan 12 00:20:33 2001 +++ squid/src/ssl.c Sat Feb 24 03:11:29 2001 @@ -484,7 +484,7 @@ 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: squid/src/stat.c diff -u squid/src/stat.c:1.8 squid/src/stat.c:1.8.10.1 --- squid/src/stat.c:1.8 Wed Feb 7 11:11:48 2001 +++ squid/src/stat.c Sat Feb 24 03:11:29 2001 @@ -345,7 +345,7 @@ statObjectsStart(StoreEntry * sentry, STOBJFLT * filter) { StatObjectsState *state; - state = CBDATA_ALLOC(StatObjectsState, NULL); + state = cbdataAlloc(StatObjectsState); state->sentry = sentry; state->filter = filter; storeLockObject(sentry); Index: squid/src/store_client.c diff -u squid/src/store_client.c:1.6 squid/src/store_client.c:1.6.14.1 --- squid/src/store_client.c:1.6 Fri Jan 12 00:20:33 2001 +++ squid/src/store_client.c Sat Feb 24 03:11:29 2001 @@ -133,7 +133,7 @@ #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: squid/src/store_digest.c diff -u squid/src/store_digest.c:1.8 squid/src/store_digest.c:1.8.10.1 --- squid/src/store_digest.c:1.8 Wed Feb 7 11:11:48 2001 +++ squid/src/store_digest.c Sat Feb 24 03:11:29 2001 @@ -352,7 +352,7 @@ 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: squid/src/store_swapout.c diff -u squid/src/store_swapout.c:1.6 squid/src/store_swapout.c:1.6.14.1 --- squid/src/store_swapout.c:1.6 Fri Jan 12 00:20:33 2001 +++ squid/src/store_swapout.c Sat Feb 24 03:11:29 2001 @@ -61,7 +61,7 @@ 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: squid/src/urn.c diff -u squid/src/urn.c:1.9 squid/src/urn.c:1.9.2.1 --- squid/src/urn.c:1.9 Fri Feb 23 13:03:31 2001 +++ squid/src/urn.c Sat Feb 24 03:11:29 2001 @@ -108,7 +108,7 @@ 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: squid/src/wais.c diff -u squid/src/wais.c:1.5 squid/src/wais.c:1.5.14.1 --- squid/src/wais.c:1.5 Fri Jan 12 00:20:34 2001 +++ squid/src/wais.c Sat Feb 24 03:11:29 2001 @@ -230,7 +230,7 @@ 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: squid/src/whois.c diff -u squid/src/whois.c:1.5 squid/src/whois.c:1.5.14.1 --- squid/src/whois.c:1.5 Fri Jan 12 00:20:34 2001 +++ squid/src/whois.c Sat Feb 24 03:11:29 2001 @@ -59,7 +59,7 @@ 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; Index: squid/src/auth/basic/auth_basic.c diff -u squid/src/auth/basic/auth_basic.c:1.9 squid/src/auth/basic/auth_basic.c:1.9.10.2 --- squid/src/auth/basic/auth_basic.c:1.9 Sat Feb 10 09:31:47 2001 +++ squid/src/auth/basic/auth_basic.c Sat Mar 3 02:23:33 2001 @@ -378,6 +378,7 @@ authBasicDataFree(basic_data * basic_auth) { } + #endif static auth_user_t * @@ -588,7 +589,7 @@ cbdataLock(data); return; } else { - r = CBDATA_ALLOC(authenticateStateData, NULL); + r = cbdataAlloc(authenticateStateData); r->handler = handler; cbdataLock(data); r->data = data; Index: squid/src/auth/digest/auth_digest.c diff -u squid/src/auth/digest/auth_digest.c:1.4 squid/src/auth/digest/auth_digest.c:1.4.10.2 --- squid/src/auth/digest/auth_digest.c:1.4 Sat Feb 10 09:31:47 2001 +++ squid/src/auth/digest/auth_digest.c Sat Mar 3 02:23:33 2001 @@ -200,7 +200,7 @@ } } -void +void authenticateDigestNonceSetup() { if (!digest_nonce_pool) @@ -212,7 +212,7 @@ } } -void +void authenticateDigestNonceShutdown() { /* @@ -235,7 +235,7 @@ debug(29, 2) ("authenticateDigestNonceShutdown: Nonce cache shutdown\n"); } -void +void authenticateDigestNonceReconfigure() { } @@ -690,7 +690,7 @@ return; } -int +int authenticateDigestDirection(auth_user_request_t * auth_user_request) { digest_request_h *digest_request; @@ -1313,7 +1313,7 @@ handler(data, NULL); return; } - r = CBDATA_ALLOC(authenticateStateData, NULL); + r = cbdataAlloc(authenticateStateData); r->handler = handler; cbdataLock(data); r->data = data; Index: squid/src/auth/ntlm/auth_ntlm.c diff -u squid/src/auth/ntlm/auth_ntlm.c:1.7 squid/src/auth/ntlm/auth_ntlm.c:1.7.12.1 --- squid/src/auth/ntlm/auth_ntlm.c:1.7 Wed Jan 31 14:20:28 2001 +++ squid/src/auth/ntlm/auth_ntlm.c Sat Feb 24 03:11:31 2001 @@ -625,7 +625,7 @@ return; } #ifdef NTLMHELPPROTOCOLV2 - r = CBDATA_ALLOC(authenticateStateData, NULL); + r = cbdataAlloc(authenticateStateData); r->handler = handler; cbdataLock(data); r->data = data; @@ -663,7 +663,7 @@ 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 @@ break; case AUTHENTICATE_STATE_RESPONSE: - r = CBDATA_ALLOC(authenticateStateData, NULL); + r = cbdataAlloc(authenticateStateData); r->handler = handler; cbdataLock(data); r->data = data; Index: squid/src/fs/aufs/store_dir_aufs.c diff -u squid/src/fs/aufs/store_dir_aufs.c:1.14 squid/src/fs/aufs/store_dir_aufs.c:1.14.2.1 --- squid/src/fs/aufs/store_dir_aufs.c:1.14 Tue Feb 20 16:10:14 2001 +++ squid/src/fs/aufs/store_dir_aufs.c Sat Feb 24 03:11:31 2001 @@ -829,7 +829,7 @@ 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: squid/src/fs/aufs/store_io_aufs.c diff -u squid/src/fs/aufs/store_io_aufs.c:1.6 squid/src/fs/aufs/store_io_aufs.c:1.6.10.1 --- squid/src/fs/aufs/store_io_aufs.c:1.6 Sun Feb 11 12:08:03 2001 +++ squid/src/fs/aufs/store_io_aufs.c Sat Feb 24 03:11:32 2001 @@ -22,6 +22,8 @@ static int storeAufsKickWriteQueue(storeIOState * sio); static CBDUNL storeAufsIOFreeEntry; +CBDATA_TYPE(storeIOState); + /* === PUBLIC =========================================================== */ /* open for reading */ @@ -51,7 +53,8 @@ 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 @@ 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: squid/src/fs/coss/store_dir_coss.c diff -u squid/src/fs/coss/store_dir_coss.c:1.10 squid/src/fs/coss/store_dir_coss.c:1.10.10.1 --- squid/src/fs/coss/store_dir_coss.c:1.10 Sat Feb 10 08:49:05 2001 +++ squid/src/fs/coss/store_dir_coss.c Sat Feb 24 03:11:32 2001 @@ -339,7 +339,7 @@ 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: squid/src/fs/coss/store_io_coss.c diff -u squid/src/fs/coss/store_io_coss.c:1.5 squid/src/fs/coss/store_io_coss.c:1.5.14.1 --- squid/src/fs/coss/store_io_coss.c:1.5 Fri Jan 12 00:20:35 2001 +++ squid/src/fs/coss/store_io_coss.c Sat Feb 24 03:11:32 2001 @@ -49,6 +49,8 @@ static CBDUNL storeCossIOFreeEntry; static CBDUNL storeCossMembufFree; +CBDATA_TYPE(storeIOState); + /* === PUBLIC =========================================================== */ /* @@ -128,7 +130,8 @@ 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 @@ 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 @@ 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: squid/src/fs/diskd/store_dir_diskd.c diff -u squid/src/fs/diskd/store_dir_diskd.c:1.18 squid/src/fs/diskd/store_dir_diskd.c:1.15.2.3 --- squid/src/fs/diskd/store_dir_diskd.c:1.18 Thu Mar 1 14:31:14 2001 +++ squid/src/fs/diskd/store_dir_diskd.c Sat Mar 3 02:23:33 2001 @@ -1021,7 +1021,7 @@ 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 @@ 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 @@ 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: squid/src/fs/diskd/store_io_diskd.c diff -u squid/src/fs/diskd/store_io_diskd.c:1.6 squid/src/fs/diskd/store_io_diskd.c:1.6.14.1 --- squid/src/fs/diskd/store_io_diskd.c:1.6 Fri Jan 12 00:20:35 2001 +++ squid/src/fs/diskd/store_io_diskd.c Sat Feb 24 03:11:33 2001 @@ -46,6 +46,8 @@ static void storeDiskdIOCallback(storeIOState * sio, int errflag); static CBDUNL storeDiskdIOFreeEntry; +CBDATA_TYPE(storeIOState); + /* === PUBLIC =========================================================== */ storeIOState * @@ -68,7 +70,8 @@ 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 @@ 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: squid/src/fs/ufs/store_dir_ufs.c diff -u squid/src/fs/ufs/store_dir_ufs.c:1.13 squid/src/fs/ufs/store_dir_ufs.c:1.13.2.1 --- squid/src/fs/ufs/store_dir_ufs.c:1.13 Tue Feb 20 16:10:14 2001 +++ squid/src/fs/ufs/store_dir_ufs.c Sat Feb 24 03:11:33 2001 @@ -825,7 +825,7 @@ 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: squid/src/fs/ufs/store_io_ufs.c diff -u squid/src/fs/ufs/store_io_ufs.c:1.5 squid/src/fs/ufs/store_io_ufs.c:1.5.14.1 --- squid/src/fs/ufs/store_io_ufs.c:1.5 Fri Jan 12 00:20:36 2001 +++ squid/src/fs/ufs/store_io_ufs.c Sat Feb 24 03:11:34 2001 @@ -42,6 +42,8 @@ static void storeUfsIOCallback(storeIOState * sio, int errflag); static CBDUNL storeUfsIOFreeEntry; +CBDATA_TYPE(storeIOState); + /* === PUBLIC =========================================================== */ storeIOState * @@ -60,7 +62,8 @@ 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 @@ 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: squid/src/repl/heap/store_repl_heap.c diff -u squid/src/repl/heap/store_repl_heap.c:1.6 squid/src/repl/heap/store_repl_heap.c:1.6.10.1 --- squid/src/repl/heap/store_repl_heap.c:1.6 Wed Feb 7 11:11:50 2001 +++ squid/src/repl/heap/store_repl_heap.c Sat Feb 24 03:11:34 2001 @@ -151,7 +151,7 @@ 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 @@ 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 @@ 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: squid/src/repl/lru/store_repl_lru.c diff -u squid/src/repl/lru/store_repl_lru.c:1.6 squid/src/repl/lru/store_repl_lru.c:1.6.10.1 --- squid/src/repl/lru/store_repl_lru.c:1.6 Wed Feb 7 11:11:50 2001 +++ squid/src/repl/lru/store_repl_lru.c Sat Feb 24 03:11:34 2001 @@ -162,7 +162,7 @@ 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 @@ 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 @@ 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 */ squid-cbdata-20010303-HEAD-20010303.new squid-cbdata-20010303-HEAD-20010303 differ: char 83, line 2