engine: zone: add small allocation optimization, reducing the size of <255 bytes allocations at the cost of less debug info

Keep it opt-in through a flag at pool alloc time.
Opt-in console related allocations, they are usually small enough strings.
This commit is contained in:
Alibek Omarov
2026-05-13 09:32:50 +05:00
parent 33b3cdb0f5
commit 0aac2e4d32
10 changed files with 382 additions and 185 deletions
+5 -2
View File
@@ -73,7 +73,10 @@ GNU General Public License for more details.
// Moved detail textures parsing and cinematic texture management to engine
// Moved creation of default textures to the engine
// 16. RefGetParm return type changed from int to intptr_t.
#define REF_API_VERSION 16
// 17. _Mem_AllocPool now takes a flags argument (see MEM_SMALL_ALLOC_OPT in engine/common/common.h).
// Pools that opt into MEM_SMALL_ALLOC_OPT use a compact 16/24-byte header for allocations
// <= 255 bytes, dropping per-allocation filename/fileline tracking.
#define REF_API_VERSION 17
#define TF_SKY (TF_SKYSIDE|TF_NOMIPMAP|TF_ALLOW_NEAREST)
#define TF_FONT (TF_NOMIPMAP|TF_CLAMP|TF_ALLOW_NEAREST)
@@ -444,7 +447,7 @@ typedef struct ref_api_s
void *(*Mod_Calloc)( int number, size_t size );
// memory
poolhandle_t (*_Mem_AllocPool)( const char *name, const char *filename, int fileline )
poolhandle_t (*_Mem_AllocPool)( const char *name, unsigned int flags, const char *filename, int fileline )
WARN_UNUSED_RESULT;
void (*_Mem_FreePool)( poolhandle_t *poolptr, const char *filename, int fileline );
void *(*_Mem_Alloc)( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline )