engine: zone: optimize memory usage a bit by compressing memheader_t better while keeping it efficient
It saves about 40 kilobytes of memory.
This commit is contained in:
parent
232d1f8583
commit
8a9b209db0
1 changed files with 17 additions and 19 deletions
|
@ -18,7 +18,7 @@ GNU General Public License for more details.
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
#define MEMHEADER_SENTINEL1 0xDEADF00DU
|
#define MEMHEADER_SENTINEL1 0xA1BAU
|
||||||
#define MEMHEADER_SENTINEL2 0xDFU
|
#define MEMHEADER_SENTINEL2 0xDFU
|
||||||
|
|
||||||
#ifdef XASH_CUSTOM_SWAP
|
#ifdef XASH_CUSTOM_SWAP
|
||||||
|
@ -51,19 +51,17 @@ static void *Q_realloc( void *mem, size_t size )
|
||||||
#define Q_realloc realloc
|
#define Q_realloc realloc
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// keep this structure as compact as possible while keeping it aligned
|
||||||
|
// on ILP32 it's 24 bytes, which is aligned to 8 byte boundary
|
||||||
|
// on LP64 it's 40 bytes, which is also aligned to 8 byte boundary
|
||||||
typedef struct memheader_s
|
typedef struct memheader_s
|
||||||
{
|
{
|
||||||
struct memheader_s *next; // next and previous memheaders in chain belonging to pool
|
struct memheader_s *next, *prev; // next and previous memheaders in chain belonging to pool
|
||||||
struct memheader_s *prev;
|
|
||||||
const char *filename; // file name and line where Mem_Alloc was called
|
const char *filename; // file name and line where Mem_Alloc was called
|
||||||
size_t size; // size of the memory after the header (excluding header and sentinel2)
|
size_t size; // size of the memory after the header (excluding header and sentinel2)
|
||||||
poolhandle_t poolptr; // pool this memheader belongs to
|
poolhandle_t poolptr; // pool this memheader belongs to
|
||||||
int fileline;
|
uint16_t fileline;
|
||||||
#if !XASH_64BIT
|
uint16_t sentinel1; // must be equal to MEMHEADER_SENTINEL1
|
||||||
uint32_t pad0; // doesn't have value, only to make Mem_Alloc return aligned addresses on ILP32
|
|
||||||
#endif
|
|
||||||
uint32_t sentinel1; // should always be MEMHEADER_SENTINEL1
|
|
||||||
|
|
||||||
// immediately followed by data, which is followed by a MEMHEADER_SENTINEL2 byte
|
// immediately followed by data, which is followed by a MEMHEADER_SENTINEL2 byte
|
||||||
} memheader_t;
|
} memheader_t;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue