diff --git a/src/mem/forward.h b/src/mem/forward.h index 8a0b287fa14..ceebcc81bd6 100644 --- a/src/mem/forward.h +++ b/src/mem/forward.h @@ -39,6 +39,7 @@ typedef void FREE(void *); /// Types of memory pool which do not yet use MEMPROXY_CLASS() API typedef enum { MEM_NONE, + MEM_16B_BUF, MEM_32B_BUF, MEM_64B_BUF, MEM_128B_BUF, @@ -53,7 +54,6 @@ typedef enum { MEM_64K_BUF, MEM_DREAD_CTRL, MEM_DWRITE_Q, - MEM_MD5_DIGEST, MEM_MAX } mem_type; diff --git a/src/mem/old_api.cc b/src/mem/old_api.cc index 461be27d02d..901b627b15a 100644 --- a/src/mem/old_api.cc +++ b/src/mem/old_api.cc @@ -27,6 +27,7 @@ #include /* forward declarations */ +static void memFree16B(void *); static void memFree32B(void *); static void memFree64B(void *); static void memFree128B(void *); @@ -140,7 +141,10 @@ memFindBufSizeType(size_t net_size, size_t * gross_size) mem_type type; size_t size; - if (net_size <= 32) { + if (net_size <= 16) { + type = MEM_16B_BUF; + size = 16; + } else if (net_size <= 32) { type = MEM_32B_BUF; size = 32; } else if (net_size <= 64) { @@ -295,6 +299,7 @@ Mem::Init(void) * that are never used or used only once; perhaps we should simply use * malloc() for those? @?@ */ + memDataInit(MEM_16B_BUF, "16B Buffer", 16, 10, false); memDataInit(MEM_32B_BUF, "32B Buffer", 32, 10, false); memDataInit(MEM_64B_BUF, "64B Buffer", 64, 10, false); memDataInit(MEM_128B_BUF, "128B Buffer", 128, 10, false); @@ -310,8 +315,6 @@ Mem::Init(void) // TODO: Carefully stop zeroing these objects memory and drop the doZero parameter memDataInit(MEM_DREAD_CTRL, "dread_ctrl", sizeof(dread_ctrl), 0, true); memDataInit(MEM_DWRITE_Q, "dwrite_q", sizeof(dwrite_q), 0, true); - memDataInit(MEM_MD5_DIGEST, "MD5 digest", SQUID_MD5_DIGEST_LENGTH, 0, true); - GetPool(MEM_MD5_DIGEST)->setChunkSize(512 * 1024); // Test that all entries are initialized for (auto t = MEM_NONE; ++t < MEM_MAX;) { @@ -350,6 +353,12 @@ memInUse(mem_type type) /* ick */ +void +memFree16B(void *p) +{ + memFree(p, MEM_16B_BUF); +} + void memFree32B(void *p) { @@ -433,6 +442,9 @@ memFreeBufFunc(size_t size) { switch (size) { + case 16: + return memFree16B; + case 32: return memFree32B; diff --git a/src/store_key_md5.cc b/src/store_key_md5.cc index b75d649ca75..2f98c6b840a 100644 --- a/src/store_key_md5.cc +++ b/src/store_key_md5.cc @@ -138,7 +138,7 @@ storeKeyPublicByRequestMethod(HttpRequest * request, const HttpRequestMethod& me cache_key * storeKeyDup(const cache_key * key) { - cache_key *dup = (cache_key *)memAllocate(MEM_MD5_DIGEST); + cache_key *dup = (cache_key *)memAllocBuf(SQUID_MD5_DIGEST_LENGTH, nullptr); memcpy(dup, key, SQUID_MD5_DIGEST_LENGTH); return dup; } @@ -153,7 +153,7 @@ storeKeyCopy(cache_key * dst, const cache_key * src) void storeKeyFree(const cache_key * key) { - memFree((void *) key, MEM_MD5_DIGEST); + memFreeBuf(SQUID_MD5_DIGEST_LENGTH, const_cast(key)); } int