Eventually you will want to either use these types outside of src/ or replace them with the BSD list macros.
I'd suggest splitting it up into something under the top level dir, rather than under src/, to avoid having to shift it twice. Stick the bulk of the dlink routines in there, and stuff the memPool allocated one under src/. Adrian On Tue, Mar 04, 2008, Amos Jeffries wrote: > Update of cvs.devel.squid-cache.org:/cvsroot/squid/squid3/src > > Modified Files: > Tag: cleanup > AuthConfig.h AuthUser.cci AuthUser.h Makefile.am > client_side_reply.cc dlink.h globals.h protos.h tools.cc > Added Files: > Tag: cleanup > dlink.cc > Log Message: > Move dlink* objects into dlink.h and dlink.cc. Plus otehr .h fixes. > > > --- NEW FILE: dlink.cc --- > /* > * $Id: dlink.cc,v 1.1.2.1 2008/03/04 01:08:47 amosjeffries Exp $ > */ > #include "dlink.h" > > /* dlink are Mem-pooled */ > #include "MemPool.h" > /* for xstrdup() */ > #include "util.h" > > > dlink_list ClientActiveRequests; > > MemAllocator *dlink_node_pool = NULL; > > dlink_node * > dlinkNodeNew() > { > if (dlink_node_pool == NULL) > dlink_node_pool = memPoolCreate("Dlink list nodes", > sizeof(dlink_node)); > > /* where should we call delete dlink_node_pool;dlink_node_pool = NULL; */ > return (dlink_node *)dlink_node_pool->alloc(); > } > > /** The node needs to be unlinked FIRST */ > void > dlinkNodeDelete(dlink_node * m) > { > if (m == NULL) > return; > > dlink_node_pool->free(m); > } > > void > dlinkAdd(void *data, dlink_node * m, dlink_list * list) > { > m->data = data; > m->prev = NULL; > m->next = list->head; > > if (list->head) > list->head->prev = m; > > list->head = m; > > if (list->tail == NULL) > list->tail = m; > } > > void > dlinkAddAfter(void *data, dlink_node * m, dlink_node * n, dlink_list * list) > { > m->data = data; > m->prev = n; > m->next = n->next; > > if (n->next) > n->next->prev = m; > else { > assert(list->tail == n); > list->tail = m; > } > > n->next = m; > } > > void > dlinkAddTail(void *data, dlink_node * m, dlink_list * list) > { > m->data = data; > m->next = NULL; > m->prev = list->tail; > > if (list->tail) > list->tail->next = m; > > list->tail = m; > > if (list->head == NULL) > list->head = m; > } > > void > dlinkDelete(dlink_node * m, dlink_list * list) > { > if (m->next) > m->next->prev = m->prev; > > if (m->prev) > m->prev->next = m->next; > > if (m == list->head) > list->head = m->next; > > if (m == list->tail) > list->tail = m->prev; > > m->next = m->prev = NULL; > } > > Index: tools.cc > =================================================================== > RCS file: /cvsroot/squid/squid3/src/tools.cc,v > retrieving revision 1.50.4.1 > retrieving revision 1.50.4.2 > diff -C2 -d -r1.50.4.1 -r1.50.4.2 > *** tools.cc 12 Feb 2008 02:48:48 -0000 1.50.4.1 > --- tools.cc 4 Mar 2008 01:08:47 -0000 1.50.4.2 > *************** > *** 85,90 **** > SQUIDCEXTERN void (*failure_notify) (const char *); > > - MemAllocator *dlink_node_pool = NULL; > - > void > releaseServerSockets(void) > --- 85,88 ---- > *************** > *** 1057,1147 **** > } > > - dlink_node * > - dlinkNodeNew() > - { > - if (dlink_node_pool == NULL) > - dlink_node_pool = memPoolCreate("Dlink list nodes", > sizeof(dlink_node)); > - > - /* where should we call delete dlink_node_pool;dlink_node_pool = NULL; > */ > - return (dlink_node *)dlink_node_pool->alloc(); > - } > - > - /* the node needs to be unlinked FIRST */ > - void > - dlinkNodeDelete(dlink_node * m) > - { > - if (m == NULL) > - return; > - > - dlink_node_pool->free(m); > - } > - > - void > - dlinkAdd(void *data, dlink_node * m, dlink_list * list) > - { > - m->data = data; > - m->prev = NULL; > - m->next = list->head; > - > - if (list->head) > - list->head->prev = m; > - > - list->head = m; > - > - if (list->tail == NULL) > - list->tail = m; > - } > - > - void > - dlinkAddAfter(void *data, dlink_node * m, dlink_node * n, dlink_list * list) > - { > - m->data = data; > - m->prev = n; > - m->next = n->next; > - > - if (n->next) > - n->next->prev = m; > - else { > - assert(list->tail == n); > - list->tail = m; > - } > - > - n->next = m; > - } > - > - void > - dlinkAddTail(void *data, dlink_node * m, dlink_list * list) > - { > - m->data = data; > - m->next = NULL; > - m->prev = list->tail; > - > - if (list->tail) > - list->tail->next = m; > - > - list->tail = m; > - > - if (list->head == NULL) > - list->head = m; > - } > - > - void > - dlinkDelete(dlink_node * m, dlink_list * list) > - { > - if (m->next) > - m->next->prev = m->prev; > - > - if (m->prev) > - m->prev->next = m->next; > - > - if (m == list->head) > - list->head = m->next; > - > - if (m == list->tail) > - list->tail = m->prev; > - > - m->next = m->prev = NULL; > - } > - > void > kb_incr(kb_t * k, size_t v) > --- 1055,1058 ---- > > Index: protos.h > =================================================================== > RCS file: /cvsroot/squid/squid3/src/protos.h,v > retrieving revision 1.95.2.3 > retrieving revision 1.95.2.4 > diff -C2 -d -r1.95.2.3 -r1.95.2.4 > *** protos.h 2 Mar 2008 11:26:58 -0000 1.95.2.3 > --- protos.h 4 Mar 2008 01:08:47 -0000 1.95.2.4 > *************** > *** 676,686 **** > > /* tools.c */ > ! #include "dlink.h" > ! SQUIDCEXTERN void dlinkAdd(void *data, dlink_node *, dlink_list *); > ! SQUIDCEXTERN void dlinkAddAfter(void *, dlink_node *, dlink_node *, > dlink_list *); > ! SQUIDCEXTERN void dlinkAddTail(void *data, dlink_node *, dlink_list *); > ! SQUIDCEXTERN void dlinkDelete(dlink_node * m, dlink_list * list); > ! SQUIDCEXTERN void dlinkNodeDelete(dlink_node * m); > ! SQUIDCEXTERN dlink_node *dlinkNodeNew(void); > > SQUIDCEXTERN void kb_incr(kb_t *, size_t); > --- 676,686 ---- > > /* tools.c */ > ! //UNUSED #include "dlink.h" > ! //UNUSED SQUIDCEXTERN void dlinkAdd(void *data, dlink_node *, dlink_list > *); > ! //UNUSED SQUIDCEXTERN void dlinkAddAfter(void *, dlink_node *, > dlink_node *, dlink_list *); > ! //UNUSED SQUIDCEXTERN void dlinkAddTail(void *data, dlink_node *, > dlink_list *); > ! //UNUSED SQUIDCEXTERN void dlinkDelete(dlink_node * m, dlink_list * > list); > ! //UNUSED SQUIDCEXTERN void dlinkNodeDelete(dlink_node * m); > ! //UNUSED SQUIDCEXTERN dlink_node *dlinkNodeNew(void); > > SQUIDCEXTERN void kb_incr(kb_t *, size_t); > > Index: client_side_reply.cc > =================================================================== > RCS file: /cvsroot/squid/squid3/src/client_side_reply.cc,v > retrieving revision 1.125.2.2 > retrieving revision 1.125.2.3 > diff -C2 -d -r1.125.2.2 -r1.125.2.3 > *** client_side_reply.cc 19 Feb 2008 11:39:40 -0000 1.125.2.2 > --- client_side_reply.cc 4 Mar 2008 01:08:47 -0000 1.125.2.3 > *************** > *** 1,3 **** > - > /* > * $Id$ > --- 1,2 ---- > *************** > *** 34,37 **** > --- 33,40 ---- > */ > > + /* for ClientActiveRequests global */ > + #include "dlink.h" > + > + /* old includes without reasons given. */ > #include "squid.h" > #include "client_side_reply.h" > *************** > *** 42,46 **** > #include "HttpRequest.h" > #include "forward.h" > - > #include "clientStream.h" > #include "AuthUserRequest.h" > --- 45,48 ---- > > Index: AuthConfig.h > =================================================================== > RCS file: /cvsroot/squid/squid3/src/AuthConfig.h,v > retrieving revision 1.3.26.1 > retrieving revision 1.3.26.2 > diff -C2 -d -r1.3.26.1 -r1.3.26.2 > *** AuthConfig.h 27 Feb 2008 04:28:57 -0000 1.3.26.1 > --- AuthConfig.h 4 Mar 2008 01:08:47 -0000 1.3.26.2 > *************** > *** 1,3 **** > - > /* > * $Id$ > --- 1,2 ---- > *************** > *** 31,52 **** > * > */ > - > #ifndef SQUID_AUTHCONFIG_H > #define SQUID_AUTHCONFIG_H > > ! /* > * I am the configuration for an auth scheme. > * Currently each scheme has only one instance of me, > * but this may change. > ! */ > ! > ! /* This class is treated like a ref counted class. > * If the children ever stop being singletons, implement the > * ref counting... > */ > - > - class AuthUserRequest; > - > - /// \ingroup AuthAPI > class AuthConfig > { > --- 30,57 ---- > * > */ > #ifndef SQUID_AUTHCONFIG_H > #define SQUID_AUTHCONFIG_H > > ! class AuthUserRequest; > ! class StoreEntry; > ! class HttpReply; > ! class HttpRequest; > ! class CacheManager; > ! > ! /* for http_hdr_type parameters-by-value */ > ! #include "HttpHeader.h" > ! > ! > ! /** > ! \ingroup AuthAPI > ! \par > * I am the configuration for an auth scheme. > * Currently each scheme has only one instance of me, > * but this may change. > ! \par > ! * This class is treated like a ref counted class. > * If the children ever stop being singletons, implement the > * ref counting... > */ > class AuthConfig > { > > Index: globals.h > =================================================================== > RCS file: /cvsroot/squid/squid3/src/globals.h,v > retrieving revision 1.33.4.2 > retrieving revision 1.33.4.3 > diff -C2 -d -r1.33.4.2 -r1.33.4.3 > *** globals.h 12 Feb 2008 02:48:48 -0000 1.33.4.2 > --- globals.h 4 Mar 2008 01:08:47 -0000 1.33.4.3 > *************** > *** 130,134 **** > extern int store_hash_buckets; /* 0 */ > extern hash_table *store_table; /* NULL */ > ! extern dlink_list ClientActiveRequests; > extern int hot_obj_count; /* 0 */ > extern const int CacheDigestHashFuncCount; /* 4 */ > --- 130,134 ---- > extern int store_hash_buckets; /* 0 */ > extern hash_table *store_table; /* NULL */ > ! //MOVED:dlink.h extern dlink_list ClientActiveRequests; > extern int hot_obj_count; /* 0 */ > extern const int CacheDigestHashFuncCount; /* 4 */ > > Index: dlink.h > =================================================================== > RCS file: /cvsroot/squid/squid3/src/dlink.h,v > retrieving revision 1.1 > retrieving revision 1.1.48.1 > diff -C2 -d -r1.1 -r1.1.48.1 > *** dlink.h 23 Apr 2006 11:27:37 -0000 1.1 > --- dlink.h 4 Mar 2008 01:08:47 -0000 1.1.48.1 > *************** > *** 1,3 **** > - > /* > * $Id$ > --- 1,2 ---- > *************** > *** 31,35 **** > * > */ > - > #ifndef SQUID_DLINK_H > #define SQUID_DLINK_H > --- 30,33 ---- > *************** > *** 48,52 **** > }; > > ! struct _dlink_list > { > dlink_node *head; > --- 46,50 ---- > }; > > ! struct dlink_list > { > dlink_node *head; > *************** > *** 54,60 **** > }; > > ! class dlink_node; > > ! typedef struct _dlink_list dlink_list; > > #endif /* SQUID_DLINK_H */ > --- 52,66 ---- > }; > > ! /* mported form globals.h */ > ! extern dlink_list ClientActiveRequests; > > ! /* imported directly from protos.h */ > ! > ! SQUIDCEXTERN void dlinkAdd(void *data, dlink_node *, dlink_list *); > ! SQUIDCEXTERN void dlinkAddAfter(void *, dlink_node *, dlink_node *, > dlink_list *); > ! SQUIDCEXTERN void dlinkAddTail(void *data, dlink_node *, dlink_list *); > ! SQUIDCEXTERN void dlinkDelete(dlink_node * m, dlink_list * list); > ! SQUIDCEXTERN void dlinkNodeDelete(dlink_node * m); > ! SQUIDCEXTERN dlink_node *dlinkNodeNew(void); > > #endif /* SQUID_DLINK_H */ > > Index: AuthUser.h > =================================================================== > RCS file: /cvsroot/squid/squid3/src/AuthUser.h,v > retrieving revision 1.6.4.2 > retrieving revision 1.6.4.3 > diff -C2 -d -r1.6.4.2 -r1.6.4.3 > *** AuthUser.h 27 Feb 2008 04:28:57 -0000 1.6.4.2 > --- AuthUser.h 4 Mar 2008 01:08:47 -0000 1.6.4.3 > *************** > *** 35,41 **** > #define SQUID_AUTHUSER_H > > - #include "IPAddress.h" > - > class AuthUserRequest; > > /** > --- 35,47 ---- > #define SQUID_AUTHUSER_H > > class AuthUserRequest; > + class AuthConfig; > + class AuthUserHashPointer; > + > + /* for auth_type_t */ > + #include "enums.h" > + > + #include "IPAddress.h" > + #include "dlink.h" > > /** > *************** > *** 60,64 **** > AuthConfig *config; > /** we only have one username associated with a given auth_user struct > */ > ! auth_user_hash_pointer *usernamehash; > /** we may have many proxy-authenticate strings that decode to the same > user */ > dlink_list proxy_auth_list; > --- 66,70 ---- > AuthConfig *config; > /** we only have one username associated with a given auth_user struct > */ > ! AuthUserHashPointer *usernamehash; > /** we may have many proxy-authenticate strings that decode to the same > user */ > dlink_list proxy_auth_list; > > Index: Makefile.am > =================================================================== > RCS file: /cvsroot/squid/squid3/src/Makefile.am,v > retrieving revision 1.138.2.7 > retrieving revision 1.138.2.8 > diff -C2 -d -r1.138.2.7 -r1.138.2.8 > *** Makefile.am 27 Feb 2008 04:28:58 -0000 1.138.2.7 > --- Makefile.am 4 Mar 2008 01:08:47 -0000 1.138.2.8 > *************** > *** 480,483 **** > --- 480,484 ---- > $(DISKIO_SOURCE) \ > dlink.h \ > + dlink.cc \ > $(DNSSOURCE) \ > enums.h \ > *************** > *** 817,820 **** > --- 818,823 ---- > $(DELAY_POOL_SOURCE) \ > disk.cc \ > + dlink.h \ > + dlink.cc \ > $(DNSSOURCE) \ > enums.h \ > > Index: AuthUser.cci > =================================================================== > RCS file: /cvsroot/squid/squid3/src/AuthUser.cci,v > retrieving revision 1.3 > retrieving revision 1.3.26.1 > diff -C2 -d -r1.3 -r1.3.26.1 > *** AuthUser.cci 9 May 2007 15:50:34 -0000 1.3 > --- AuthUser.cci 4 Mar 2008 01:08:47 -0000 1.3.26.1 > *************** > *** 1,3 **** > - > /* > * $Id$ > --- 1,2 ---- > *************** > *** 35,38 **** > --- 34,42 ---- > */ > > + /* for assert() */ > + #include "assert.h" > + /* for xstrdup() */ > + #include "util.h" > + > char const * > AuthUser::username () const