From 84abff7fb830b8da5dd91897debf9f6fe16fdbad Mon Sep 17 00:00:00 2001 From: Jordan Bancino Date: Wed, 2 Nov 2022 16:46:22 +0000 Subject: [PATCH] Tune the memory table size a little bit. No idea if this hurts or helps, actually, but now we have a tunable constant, instead of a magic number. --- src/Memory.c | 6 ++++-- src/include/Constants.h | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Memory.c b/src/Memory.c index d9844f9..0994a91 100644 --- a/src/Memory.c +++ b/src/Memory.c @@ -23,6 +23,8 @@ */ #include +#include + #include #include #include @@ -56,7 +58,7 @@ MemoryInsert(MemoryInfo * a) if (!allocations) { - allocationsSize = 64; + allocationsSize = TELODENDRIA_MEMORY_TABLE_CHUNK; allocations = calloc(allocationsSize, sizeof(void *)); if (!allocations) { @@ -70,7 +72,7 @@ MemoryInsert(MemoryInfo * a) size_t tmpAllocationsSize = allocationsSize; MemoryInfo **tmpAllocations; - allocationsSize *= 2; + allocationsSize += TELODENDRIA_MEMORY_TABLE_CHUNK; tmpAllocations = calloc(allocationsSize, sizeof(void *)); if (!tmpAllocations) diff --git a/src/include/Constants.h b/src/include/Constants.h index b317329..e95d2cb 100644 --- a/src/include/Constants.h +++ b/src/include/Constants.h @@ -28,4 +28,8 @@ #define TELODENDRIA_STRING_CHUNK 64 #endif +#ifndef TELODENDRIA_MEMORY_TABLE_CHUNK +#define TELODENDRIA_MEMORY_TABLE_CHUNK 256 +#endif + #endif