From: Amos Jeffries Date: Mon, 2 Feb 2015 20:02:55 +0000 (-0800) Subject: Cleanup: migrate AclSizeLimit to CBDATA_CLASS API X-Git-Tag: merge-candidate-3-v1~298 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d21b3722d4e6404b1ef38cbb28a0011c4fbd5b05;p=thirdparty%2Fsquid.git Cleanup: migrate AclSizeLimit to CBDATA_CLASS API --- diff --git a/src/acl/AclSizeLimit.cc b/src/acl/AclSizeLimit.cc new file mode 100644 index 0000000000..0679474f59 --- /dev/null +++ b/src/acl/AclSizeLimit.cc @@ -0,0 +1,19 @@ +/* + * Copyright (C) 1996-2015 The Squid Software Foundation and contributors + * + * Squid software is distributed under GPLv2+ license and includes + * contributions from numerous individuals and organizations. + * Please see the COPYING and CONTRIBUTORS files for details. + */ + +#include "squid.h" +#include "acl/AclSizeLimit.h" +#include "acl/Gadgets.h" + +CBDATA_CLASS_INIT(AclSizeLimit); + +AclSizeLimit::~AclSizeLimit() +{ + aclDestroyAclList(&aclList); + delete next; +} diff --git a/src/acl/AclSizeLimit.h b/src/acl/AclSizeLimit.h index 9b59d649bb..3ef314b661 100644 --- a/src/acl/AclSizeLimit.h +++ b/src/acl/AclSizeLimit.h @@ -10,12 +10,17 @@ #define SQUID_ACLSIZELIMIT_H_ #include "acl/forward.h" +#include "cbdata.h" /// representation of a class of Size-limit ACLs -// a POD. TODO: convert to new ACL framework class AclSizeLimit { + CBDATA_CLASS(AclSizeLimit); + public: + AclSizeLimit() : next(NULL), aclList(NULL), size(0) {} + ~AclSizeLimit(); + AclSizeLimit *next; ACLList *aclList; int64_t size; diff --git a/src/acl/Makefile.am b/src/acl/Makefile.am index a7e97f5167..61117c66be 100644 --- a/src/acl/Makefile.am +++ b/src/acl/Makefile.am @@ -136,6 +136,7 @@ libacls_la_SOURCES = \ AclDenyInfoList.h \ Gadgets.cc \ Gadgets.h \ + AclSizeLimit.cc \ AclSizeLimit.h ## Add conditional sources diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 6cd55985df..92fc0a0deb 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -1510,14 +1510,10 @@ free_acl_nfmark(acl_nfmark ** head) } #endif /* SO_MARK */ -CBDATA_TYPE(AclSizeLimit); - static void dump_acl_b_size_t(StoreEntry * entry, const char *name, AclSizeLimit * head) { - AclSizeLimit *l; - - for (l = head; l; l = l->next) { + for (AclSizeLimit *l = head; l; l = l->next) { if (l->size != -1) storeAppendPrintf(entry, "%s %d %s\n", name, (int) l->size, B_BYTES_STR); else @@ -1529,27 +1525,16 @@ dump_acl_b_size_t(StoreEntry * entry, const char *name, AclSizeLimit * head) } } -static void -freed_acl_b_size_t(void *data) -{ - AclSizeLimit *l = static_cast(data); - aclDestroyAclList(&l->aclList); -} - static void parse_acl_b_size_t(AclSizeLimit ** head) { - AclSizeLimit *l; - AclSizeLimit **tail = head; /* sane name below */ - - CBDATA_INIT_TYPE_FREECB(AclSizeLimit, freed_acl_b_size_t); - - l = cbdataAlloc(AclSizeLimit); + AclSizeLimit *l = new AclSizeLimit; parse_b_int64_t(&l->size); aclParseAclList(LegacyParser, &l->aclList, l->size); + AclSizeLimit **tail = head; /* sane name below */ while (*tail) tail = &(*tail)->next; @@ -1559,12 +1544,8 @@ parse_acl_b_size_t(AclSizeLimit ** head) static void free_acl_b_size_t(AclSizeLimit ** head) { - while (*head) { - AclSizeLimit *l = *head; - *head = l->next; - l->next = NULL; - cbdataFree(l); - } + delete *head; + *head = NULL; } #if USE_DELAY_POOLS