engine: replace pool pointer by pool handle
This commit is contained in:
parent
43f1137565
commit
9313f7e80e
22 changed files with 96 additions and 65 deletions
|
@ -291,7 +291,7 @@ typedef struct model_s
|
||||||
// shared modelinfo
|
// shared modelinfo
|
||||||
modtype_t type; // model type
|
modtype_t type; // model type
|
||||||
int numframes; // sprite's framecount
|
int numframes; // sprite's framecount
|
||||||
byte *mempool; // private mempool (was synctype)
|
poolhandle_t mempool; // private mempool (was synctype)
|
||||||
int flags; // hl compatibility
|
int flags; // hl compatibility
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -20,6 +20,7 @@ typedef byte rgba_t[4]; // unsigned byte colorpack
|
||||||
typedef byte rgb_t[3]; // unsigned byte colorpack
|
typedef byte rgb_t[3]; // unsigned byte colorpack
|
||||||
typedef vec_t matrix3x4[3][4];
|
typedef vec_t matrix3x4[3][4];
|
||||||
typedef vec_t matrix4x4[4][4];
|
typedef vec_t matrix4x4[4][4];
|
||||||
|
typedef uint32_t poolhandle_t;
|
||||||
|
|
||||||
#undef true
|
#undef true
|
||||||
#undef false
|
#undef false
|
||||||
|
|
|
@ -437,7 +437,7 @@ typedef struct
|
||||||
void *hInstance; // pointer to client.dll
|
void *hInstance; // pointer to client.dll
|
||||||
cldll_func_t dllFuncs; // dll exported funcs
|
cldll_func_t dllFuncs; // dll exported funcs
|
||||||
render_interface_t drawFuncs; // custom renderer support
|
render_interface_t drawFuncs; // custom renderer support
|
||||||
byte *mempool; // client edicts pool
|
poolhandle_t mempool; // client edicts pool
|
||||||
string mapname; // map name
|
string mapname; // map name
|
||||||
string maptitle; // display map title
|
string maptitle; // display map title
|
||||||
string itemspath; // path to items description for auto-complete func
|
string itemspath; // path to items description for auto-complete func
|
||||||
|
@ -496,7 +496,7 @@ typedef struct
|
||||||
void *hInstance; // pointer to client.dll
|
void *hInstance; // pointer to client.dll
|
||||||
UI_FUNCTIONS dllFuncs; // dll exported funcs
|
UI_FUNCTIONS dllFuncs; // dll exported funcs
|
||||||
UI_EXTENDED_FUNCTIONS dllFuncs2; // fwgs extension
|
UI_EXTENDED_FUNCTIONS dllFuncs2; // fwgs extension
|
||||||
byte *mempool; // client edicts pool
|
poolhandle_t mempool; // client edicts pool
|
||||||
|
|
||||||
cl_entity_t playermodel; // uiPlayerSetup drawing model
|
cl_entity_t playermodel; // uiPlayerSetup drawing model
|
||||||
player_info_t playerinfo; // local playerinfo
|
player_info_t playerinfo; // local playerinfo
|
||||||
|
@ -534,7 +534,7 @@ typedef struct
|
||||||
|
|
||||||
keydest_t key_dest;
|
keydest_t key_dest;
|
||||||
|
|
||||||
byte *mempool; // client premamnent pool: edicts etc
|
poolhandle_t mempool; // client premamnent pool: edicts etc
|
||||||
|
|
||||||
netadr_t hltv_listen_address;
|
netadr_t hltv_listen_address;
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ struct touch_s
|
||||||
qboolean initialized;
|
qboolean initialized;
|
||||||
qboolean config_loaded;
|
qboolean config_loaded;
|
||||||
touchbuttonlist_t list_user, list_edit;
|
touchbuttonlist_t list_user, list_edit;
|
||||||
byte *mempool;
|
poolhandle_t mempool;
|
||||||
touchState state;
|
touchState state;
|
||||||
|
|
||||||
int look_finger;
|
int look_finger;
|
||||||
|
|
|
@ -178,7 +178,7 @@ static int pfnGetStudioModelInterface( int version, struct r_studio_interface_s
|
||||||
0;
|
0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static byte *pfnImage_GetPool( void )
|
static poolhandle_t pfnImage_GetPool( void )
|
||||||
{
|
{
|
||||||
return host.imagepool;
|
return host.imagepool;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ GNU General Public License for more details.
|
||||||
#define SND_CLIP_DISTANCE 1000.0f
|
#define SND_CLIP_DISTANCE 1000.0f
|
||||||
|
|
||||||
dma_t dma;
|
dma_t dma;
|
||||||
byte *sndpool;
|
poolhandle_t sndpool;
|
||||||
static soundfade_t soundfade;
|
static soundfade_t soundfade;
|
||||||
channel_t channels[MAX_CHANNELS];
|
channel_t channels[MAX_CHANNELS];
|
||||||
sound_t ambient_sfx[NUM_AMBIENTS];
|
sound_t ambient_sfx[NUM_AMBIENTS];
|
||||||
|
|
|
@ -16,7 +16,7 @@ GNU General Public License for more details.
|
||||||
#ifndef SOUND_H
|
#ifndef SOUND_H
|
||||||
#define SOUND_H
|
#define SOUND_H
|
||||||
|
|
||||||
extern byte *sndpool;
|
extern poolhandle_t sndpool;
|
||||||
|
|
||||||
#include "xash3d_mathlib.h"
|
#include "xash3d_mathlib.h"
|
||||||
|
|
||||||
|
|
|
@ -842,7 +842,7 @@ Cache_Check
|
||||||
consistency check
|
consistency check
|
||||||
====================
|
====================
|
||||||
*/
|
*/
|
||||||
void *Cache_Check( byte *mempool, cache_user_t *c )
|
void *Cache_Check( poolhandle_t mempool, cache_user_t *c )
|
||||||
{
|
{
|
||||||
if( !c->data )
|
if( !c->data )
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1177,7 +1177,7 @@ qboolean COM_IsSafeFileToDownload( const char *filename )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *_copystring( byte *mempool, const char *s, const char *filename, int fileline )
|
char *_copystring( poolhandle_t mempool, const char *s, const char *filename, int fileline )
|
||||||
{
|
{
|
||||||
char *b;
|
char *b;
|
||||||
|
|
||||||
|
|
|
@ -392,7 +392,7 @@ typedef struct host_parm_s
|
||||||
uint type; // running at
|
uint type; // running at
|
||||||
jmp_buf abortframe; // abort current frame
|
jmp_buf abortframe; // abort current frame
|
||||||
dword errorframe; // to prevent multiple host error
|
dword errorframe; // to prevent multiple host error
|
||||||
byte *mempool; // static mempool for misc allocations
|
poolhandle_t mempool; // static mempool for misc allocations
|
||||||
string finalmsg; // server shutdown final message
|
string finalmsg; // server shutdown final message
|
||||||
string downloadfile; // filename to be downloading
|
string downloadfile; // filename to be downloading
|
||||||
int downloadcount; // how many files remain to downloading
|
int downloadcount; // how many files remain to downloading
|
||||||
|
@ -446,8 +446,8 @@ typedef struct host_parm_s
|
||||||
char rootdir[MAX_OSPATH]; // member root directory
|
char rootdir[MAX_OSPATH]; // member root directory
|
||||||
char rodir[MAX_OSPATH]; // readonly root
|
char rodir[MAX_OSPATH]; // readonly root
|
||||||
char gamefolder[MAX_QPATH]; // it's a default gamefolder
|
char gamefolder[MAX_QPATH]; // it's a default gamefolder
|
||||||
byte *imagepool; // imagelib mempool
|
poolhandle_t imagepool; // imagelib mempool
|
||||||
byte *soundpool; // soundlib mempool
|
poolhandle_t soundpool; // soundlib mempool
|
||||||
|
|
||||||
uint features; // custom features that enables by mod-maker request
|
uint features; // custom features that enables by mod-maker request
|
||||||
|
|
||||||
|
@ -505,14 +505,14 @@ void Cmd_ForwardToServer( void );
|
||||||
// zone.c
|
// zone.c
|
||||||
//
|
//
|
||||||
void Memory_Init( void );
|
void Memory_Init( void );
|
||||||
void *_Mem_Realloc( byte *poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline );
|
void *_Mem_Realloc( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline );
|
||||||
void *_Mem_Alloc( byte *poolptr, size_t size, qboolean clear, const char *filename, int fileline );
|
void *_Mem_Alloc( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline );
|
||||||
byte *_Mem_AllocPool( const char *name, const char *filename, int fileline );
|
poolhandle_t _Mem_AllocPool( const char *name, const char *filename, int fileline );
|
||||||
void _Mem_FreePool( byte **poolptr, const char *filename, int fileline );
|
void _Mem_FreePool( poolhandle_t *poolptr, const char *filename, int fileline );
|
||||||
void _Mem_EmptyPool( byte *poolptr, const char *filename, int fileline );
|
void _Mem_EmptyPool( poolhandle_t poolptr, const char *filename, int fileline );
|
||||||
void _Mem_Free( void *data, const char *filename, int fileline );
|
void _Mem_Free( void *data, const char *filename, int fileline );
|
||||||
void _Mem_Check( const char *filename, int fileline );
|
void _Mem_Check( const char *filename, int fileline );
|
||||||
qboolean Mem_IsAllocatedExt( byte *poolptr, void *data );
|
qboolean Mem_IsAllocatedExt( poolhandle_t poolptr, void *data );
|
||||||
void Mem_PrintList( size_t minallocationsize );
|
void Mem_PrintList( size_t minallocationsize );
|
||||||
void Mem_PrintStats( void );
|
void Mem_PrintStats( void );
|
||||||
|
|
||||||
|
@ -746,7 +746,7 @@ cvar_t *pfnCVarGetPointer( const char *szVarName );
|
||||||
int pfnDrawConsoleString( int x, int y, char *string );
|
int pfnDrawConsoleString( int x, int y, char *string );
|
||||||
void pfnDrawSetTextColor( float r, float g, float b );
|
void pfnDrawSetTextColor( float r, float g, float b );
|
||||||
void pfnDrawConsoleStringLen( const char *pText, int *length, int *height );
|
void pfnDrawConsoleStringLen( const char *pText, int *length, int *height );
|
||||||
void *Cache_Check( byte *mempool, struct cache_user_s *c );
|
void *Cache_Check( poolhandle_t mempool, struct cache_user_s *c );
|
||||||
void COM_TrimSpace( const char *source, char *dest );
|
void COM_TrimSpace( const char *source, char *dest );
|
||||||
edict_t* pfnPEntityOfEntIndex( int iEntIndex );
|
edict_t* pfnPEntityOfEntIndex( int iEntIndex );
|
||||||
void pfnGetModelBounds( model_t *mod, float *mins, float *maxs );
|
void pfnGetModelBounds( model_t *mod, float *mins, float *maxs );
|
||||||
|
@ -765,7 +765,7 @@ float pfnTime( void );
|
||||||
#define copystring( s ) _copystring( host.mempool, s, __FILE__, __LINE__ )
|
#define copystring( s ) _copystring( host.mempool, s, __FILE__, __LINE__ )
|
||||||
#define SV_CopyString( s ) _copystring( svgame.stringspool, s, __FILE__, __LINE__ )
|
#define SV_CopyString( s ) _copystring( svgame.stringspool, s, __FILE__, __LINE__ )
|
||||||
#define freestring( s ) if( s != NULL ) { Mem_Free( s ); s = NULL; }
|
#define freestring( s ) if( s != NULL ) { Mem_Free( s ); s = NULL; }
|
||||||
char *_copystring( byte *mempool, const char *s, const char *filename, int fileline );
|
char *_copystring( poolhandle_t mempool, const char *s, const char *filename, int fileline );
|
||||||
|
|
||||||
// CS:CS engfuncs (stubs)
|
// CS:CS engfuncs (stubs)
|
||||||
void *pfnSequenceGet( const char *fileName, const char *entryName );
|
void *pfnSequenceGet( const char *fileName, const char *entryName );
|
||||||
|
|
|
@ -101,7 +101,7 @@ struct wfile_s
|
||||||
string filename;
|
string filename;
|
||||||
int infotableofs;
|
int infotableofs;
|
||||||
int numlumps;
|
int numlumps;
|
||||||
byte *mempool; // W_ReadLump temp buffers
|
poolhandle_t mempool; // W_ReadLump temp buffers
|
||||||
file_t *handle;
|
file_t *handle;
|
||||||
dlumpinfo_t *lumps;
|
dlumpinfo_t *lumps;
|
||||||
time_t filetime;
|
time_t filetime;
|
||||||
|
@ -144,7 +144,7 @@ typedef struct searchpath_s
|
||||||
struct searchpath_s *next;
|
struct searchpath_s *next;
|
||||||
} searchpath_t;
|
} searchpath_t;
|
||||||
|
|
||||||
static byte *fs_mempool;
|
static poolhandle_t fs_mempool;
|
||||||
static searchpath_t *fs_searchpaths = NULL; // chain
|
static searchpath_t *fs_searchpaths = NULL; // chain
|
||||||
static searchpath_t fs_directpath; // static direct path
|
static searchpath_t fs_directpath; // static direct path
|
||||||
static char fs_basedir[MAX_SYSPATH]; // base game directory
|
static char fs_basedir[MAX_SYSPATH]; // base game directory
|
||||||
|
|
|
@ -1305,7 +1305,7 @@ static void Mod_MakeHull0( void )
|
||||||
Mod_SetupHull
|
Mod_SetupHull
|
||||||
=================
|
=================
|
||||||
*/
|
*/
|
||||||
static void Mod_SetupHull( dbspmodel_t *bmod, model_t *mod, byte *mempool, int headnode, int hullnum )
|
static void Mod_SetupHull( dbspmodel_t *bmod, model_t *mod, poolhandle_t mempool, int headnode, int hullnum )
|
||||||
{
|
{
|
||||||
hull_t *hull = &mod->hulls[hullnum];
|
hull_t *hull = &mod->hulls[hullnum];
|
||||||
int count;
|
int count;
|
||||||
|
@ -1469,7 +1469,7 @@ for embedded submodels
|
||||||
static void Mod_SetupSubmodels( dbspmodel_t *bmod )
|
static void Mod_SetupSubmodels( dbspmodel_t *bmod )
|
||||||
{
|
{
|
||||||
qboolean colored = false;
|
qboolean colored = false;
|
||||||
byte *mempool;
|
poolhandle_t mempool;
|
||||||
char *ents;
|
char *ents;
|
||||||
model_t *mod;
|
model_t *mod;
|
||||||
dmodel_t *bm;
|
dmodel_t *bm;
|
||||||
|
@ -1550,7 +1550,7 @@ static void Mod_SetupSubmodels( dbspmodel_t *bmod )
|
||||||
loadmodel = Mod_FindName( name, true );
|
loadmodel = Mod_FindName( name, true );
|
||||||
*loadmodel = *mod;
|
*loadmodel = *mod;
|
||||||
Q_strncpy( loadmodel->name, name, sizeof( loadmodel->name ));
|
Q_strncpy( loadmodel->name, name, sizeof( loadmodel->name ));
|
||||||
loadmodel->mempool = NULL;
|
loadmodel->mempool = 0;
|
||||||
mod = loadmodel;
|
mod = loadmodel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,7 @@ typedef struct world_static_s
|
||||||
|
|
||||||
#ifndef REF_DLL
|
#ifndef REF_DLL
|
||||||
extern world_static_t world;
|
extern world_static_t world;
|
||||||
extern byte *com_studiocache;
|
extern poolhandle_t com_studiocache;
|
||||||
extern model_t *loadmodel;
|
extern model_t *loadmodel;
|
||||||
extern convar_t *mod_studiocache;
|
extern convar_t *mod_studiocache;
|
||||||
extern convar_t *r_wadtextures;
|
extern convar_t *r_wadtextures;
|
||||||
|
|
|
@ -27,7 +27,7 @@ GNU General Public License for more details.
|
||||||
static model_info_t mod_crcinfo[MAX_MODELS];
|
static model_info_t mod_crcinfo[MAX_MODELS];
|
||||||
static model_t mod_known[MAX_MODELS];
|
static model_t mod_known[MAX_MODELS];
|
||||||
static int mod_numknown = 0;
|
static int mod_numknown = 0;
|
||||||
byte *com_studiocache; // cache for submodels
|
poolhandle_t com_studiocache; // cache for submodels
|
||||||
convar_t *mod_studiocache;
|
convar_t *mod_studiocache;
|
||||||
convar_t *r_wadtextures;
|
convar_t *r_wadtextures;
|
||||||
convar_t *r_showhull;
|
convar_t *r_showhull;
|
||||||
|
|
|
@ -92,7 +92,7 @@ convar_t *net_qport;
|
||||||
int net_drop;
|
int net_drop;
|
||||||
netadr_t net_from;
|
netadr_t net_from;
|
||||||
sizebuf_t net_message;
|
sizebuf_t net_message;
|
||||||
byte *net_mempool;
|
static poolhandle_t net_mempool;
|
||||||
byte net_message_buffer[NET_MAX_MESSAGE];
|
byte net_message_buffer[NET_MAX_MESSAGE];
|
||||||
|
|
||||||
const char *ns_strings[NS_COUNT] =
|
const char *ns_strings[NS_COUNT] =
|
||||||
|
|
|
@ -50,19 +50,44 @@ typedef struct mempool_s
|
||||||
struct mempool_s *next; // linked into global mempool list
|
struct mempool_s *next; // linked into global mempool list
|
||||||
const char *filename; // file name and line where Mem_AllocPool was called
|
const char *filename; // file name and line where Mem_AllocPool was called
|
||||||
int fileline;
|
int fileline;
|
||||||
|
poolhandle_t idx;
|
||||||
char name[64]; // name of the pool
|
char name[64]; // name of the pool
|
||||||
uint sentinel2; // should always be MEMHEADER_SENTINEL1
|
uint sentinel2; // should always be MEMHEADER_SENTINEL1
|
||||||
} mempool_t;
|
} mempool_t;
|
||||||
|
|
||||||
mempool_t *poolchain = NULL; // critical stuff
|
static mempool_t *poolchain = NULL; // critical stuff
|
||||||
|
|
||||||
void *_Mem_Alloc( byte *poolptr, size_t size, qboolean clear, const char *filename, int fileline )
|
// a1ba: due to mempool being passed with the model through reused 32-bit field
|
||||||
|
// which makes engine incompatible with 64-bit pointers I changed mempool type
|
||||||
|
// from pointer to 32-bit handle, thankfully mempool structure is private
|
||||||
|
// But! Mempools are handled through linked list so we can't index them safely
|
||||||
|
static uint lastidx = 0;
|
||||||
|
|
||||||
|
static mempool_t *Mem_FindPool( poolhandle_t poolptr )
|
||||||
|
{
|
||||||
|
mempool_t *pool;
|
||||||
|
|
||||||
|
for( pool = poolchain; pool; pool = pool->next )
|
||||||
|
{
|
||||||
|
if( pool->idx == poolptr )
|
||||||
|
return pool;
|
||||||
|
}
|
||||||
|
|
||||||
|
Sys_Error( "%s: not allocated or double freed pool %d", __FUNCTION__, poolptr );
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *_Mem_Alloc( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline )
|
||||||
{
|
{
|
||||||
memheader_t *mem;
|
memheader_t *mem;
|
||||||
mempool_t *pool = (mempool_t *)poolptr;
|
mempool_t *pool;
|
||||||
|
|
||||||
if( size <= 0 ) return NULL;
|
if( size <= 0 ) return NULL;
|
||||||
if( poolptr == NULL ) Sys_Error( "Mem_Alloc: pool == NULL (alloc at %s:%i)\n", filename, fileline );
|
if( !poolptr ) Sys_Error( "Mem_Alloc: pool == NULL (alloc at %s:%i)\n", filename, fileline );
|
||||||
|
|
||||||
|
pool = Mem_FindPool( poolptr );
|
||||||
|
|
||||||
pool->totalsize += size;
|
pool->totalsize += size;
|
||||||
|
|
||||||
// big allocations are not clumped
|
// big allocations are not clumped
|
||||||
|
@ -147,7 +172,7 @@ void _Mem_Free( void *data, const char *filename, int fileline )
|
||||||
Mem_FreeBlock((memheader_t *)((byte *)data - sizeof( memheader_t )), filename, fileline );
|
Mem_FreeBlock((memheader_t *)((byte *)data - sizeof( memheader_t )), filename, fileline );
|
||||||
}
|
}
|
||||||
|
|
||||||
void *_Mem_Realloc( byte *poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline )
|
void *_Mem_Realloc( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline )
|
||||||
{
|
{
|
||||||
memheader_t *memhdr = NULL;
|
memheader_t *memhdr = NULL;
|
||||||
char *nb;
|
char *nb;
|
||||||
|
@ -172,12 +197,16 @@ void *_Mem_Realloc( byte *poolptr, void *memptr, size_t size, qboolean clear, co
|
||||||
return (void *)nb;
|
return (void *)nb;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte *_Mem_AllocPool( const char *name, const char *filename, int fileline )
|
poolhandle_t _Mem_AllocPool( const char *name, const char *filename, int fileline )
|
||||||
{
|
{
|
||||||
mempool_t *pool;
|
mempool_t *pool;
|
||||||
|
|
||||||
pool = (mempool_t *)Q_malloc( sizeof( mempool_t ));
|
pool = (mempool_t *)Q_malloc( sizeof( mempool_t ));
|
||||||
if( pool == NULL ) Sys_Error( "Mem_AllocPool: out of memory (allocpool at %s:%i)\n", filename, fileline );
|
if( pool == NULL )
|
||||||
|
{
|
||||||
|
Sys_Error( "Mem_AllocPool: out of memory (allocpool at %s:%i)\n", filename, fileline );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
memset( pool, 0, sizeof( mempool_t ));
|
memset( pool, 0, sizeof( mempool_t ));
|
||||||
|
|
||||||
// fill header
|
// fill header
|
||||||
|
@ -190,17 +219,18 @@ byte *_Mem_AllocPool( const char *name, const char *filename, int fileline )
|
||||||
pool->realsize = sizeof( mempool_t );
|
pool->realsize = sizeof( mempool_t );
|
||||||
Q_strncpy( pool->name, name, sizeof( pool->name ));
|
Q_strncpy( pool->name, name, sizeof( pool->name ));
|
||||||
pool->next = poolchain;
|
pool->next = poolchain;
|
||||||
|
pool->idx = ++lastidx;
|
||||||
poolchain = pool;
|
poolchain = pool;
|
||||||
|
|
||||||
return (byte *)pool;
|
return pool->idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _Mem_FreePool( byte **poolptr, const char *filename, int fileline )
|
void _Mem_FreePool( poolhandle_t *poolptr, const char *filename, int fileline )
|
||||||
{
|
{
|
||||||
mempool_t *pool = (mempool_t *)*poolptr;
|
mempool_t *pool;
|
||||||
mempool_t **chainaddress;
|
mempool_t **chainaddress;
|
||||||
|
|
||||||
if( pool )
|
if( *poolptr && ( pool = Mem_FindPool( *poolptr )))
|
||||||
{
|
{
|
||||||
// unlink pool from chain
|
// unlink pool from chain
|
||||||
for( chainaddress = &poolchain; *chainaddress && *chainaddress != pool; chainaddress = &((*chainaddress)->next));
|
for( chainaddress = &poolchain; *chainaddress && *chainaddress != pool; chainaddress = &((*chainaddress)->next));
|
||||||
|
@ -214,14 +244,14 @@ void _Mem_FreePool( byte **poolptr, const char *filename, int fileline )
|
||||||
// free the pool itself
|
// free the pool itself
|
||||||
memset( pool, 0xBF, sizeof( mempool_t ));
|
memset( pool, 0xBF, sizeof( mempool_t ));
|
||||||
Q_free( pool );
|
Q_free( pool );
|
||||||
*poolptr = NULL;
|
*poolptr = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _Mem_EmptyPool( byte *poolptr, const char *filename, int fileline )
|
void _Mem_EmptyPool( poolhandle_t poolptr, const char *filename, int fileline )
|
||||||
{
|
{
|
||||||
mempool_t *pool = (mempool_t *)poolptr;
|
mempool_t *pool = Mem_FindPool( poolptr );
|
||||||
if( poolptr == NULL ) Sys_Error( "Mem_EmptyPool: pool == NULL (emptypool at %s:%i)\n", filename, fileline );
|
if( !poolptr ) Sys_Error( "Mem_EmptyPool: pool == NULL (emptypool at %s:%i)\n", filename, fileline );
|
||||||
|
|
||||||
if( pool->sentinel1 != MEMHEADER_SENTINEL1 ) Sys_Error( "Mem_EmptyPool: trashed pool sentinel 1 (allocpool at %s:%i, emptypool at %s:%i)\n", pool->filename, pool->fileline, filename, fileline );
|
if( pool->sentinel1 != MEMHEADER_SENTINEL1 ) Sys_Error( "Mem_EmptyPool: trashed pool sentinel 1 (allocpool at %s:%i, emptypool at %s:%i)\n", pool->filename, pool->fileline, filename, fileline );
|
||||||
if( pool->sentinel2 != MEMHEADER_SENTINEL1 ) Sys_Error( "Mem_EmptyPool: trashed pool sentinel 2 (allocpool at %s:%i, emptypool at %s:%i)\n", pool->filename, pool->fileline, filename, fileline );
|
if( pool->sentinel2 != MEMHEADER_SENTINEL1 ) Sys_Error( "Mem_EmptyPool: trashed pool sentinel 2 (allocpool at %s:%i, emptypool at %s:%i)\n", pool->filename, pool->fileline, filename, fileline );
|
||||||
|
@ -230,7 +260,7 @@ void _Mem_EmptyPool( byte *poolptr, const char *filename, int fileline )
|
||||||
while( pool->chain ) Mem_FreeBlock( pool->chain, filename, fileline );
|
while( pool->chain ) Mem_FreeBlock( pool->chain, filename, fileline );
|
||||||
}
|
}
|
||||||
|
|
||||||
qboolean Mem_CheckAlloc( mempool_t *pool, void *data )
|
static qboolean Mem_CheckAlloc( mempool_t *pool, void *data )
|
||||||
{
|
{
|
||||||
memheader_t *header, *target;
|
memheader_t *header, *target;
|
||||||
|
|
||||||
|
@ -256,15 +286,15 @@ qboolean Mem_CheckAlloc( mempool_t *pool, void *data )
|
||||||
Check pointer for memory
|
Check pointer for memory
|
||||||
========================
|
========================
|
||||||
*/
|
*/
|
||||||
qboolean Mem_IsAllocatedExt( byte *poolptr, void *data )
|
qboolean Mem_IsAllocatedExt( poolhandle_t poolptr, void *data )
|
||||||
{
|
{
|
||||||
mempool_t *pool = NULL;
|
mempool_t *pool = NULL;
|
||||||
if( poolptr ) pool = (mempool_t *)poolptr;
|
if( poolptr ) pool = Mem_FindPool( poolptr );
|
||||||
|
|
||||||
return Mem_CheckAlloc( pool, data );
|
return Mem_CheckAlloc( pool, data );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mem_CheckHeaderSentinels( void *data, const char *filename, int fileline )
|
static void Mem_CheckHeaderSentinels( void *data, const char *filename, int fileline )
|
||||||
{
|
{
|
||||||
memheader_t *mem;
|
memheader_t *mem;
|
||||||
|
|
||||||
|
|
|
@ -356,10 +356,10 @@ typedef struct ref_api_s
|
||||||
int (*pfnGetStudioModelInterface)( int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio );
|
int (*pfnGetStudioModelInterface)( int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio );
|
||||||
|
|
||||||
// memory
|
// memory
|
||||||
byte *(*_Mem_AllocPool)( const char *name, const char *filename, int fileline );
|
poolhandle_t (*_Mem_AllocPool)( const char *name, const char *filename, int fileline );
|
||||||
void (*_Mem_FreePool)( byte **poolptr, const char *filename, int fileline );
|
void (*_Mem_FreePool)( poolhandle_t *poolptr, const char *filename, int fileline );
|
||||||
void *(*_Mem_Alloc)( byte *poolptr, size_t size, qboolean clear, const char *filename, int fileline );
|
void *(*_Mem_Alloc)( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline );
|
||||||
void *(*_Mem_Realloc)( byte *poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline );
|
void *(*_Mem_Realloc)( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline );
|
||||||
void (*_Mem_Free)( void *data, const char *filename, int fileline );
|
void (*_Mem_Free)( void *data, const char *filename, int fileline );
|
||||||
|
|
||||||
// library management
|
// library management
|
||||||
|
@ -424,7 +424,7 @@ typedef struct ref_api_s
|
||||||
rgbdata_t *(*FS_CopyImage)( rgbdata_t *in );
|
rgbdata_t *(*FS_CopyImage)( rgbdata_t *in );
|
||||||
void (*FS_FreeImage)( rgbdata_t *pack );
|
void (*FS_FreeImage)( rgbdata_t *pack );
|
||||||
void (*Image_SetMDLPointer)( byte *p );
|
void (*Image_SetMDLPointer)( byte *p );
|
||||||
byte *(*Image_GetPool)( void );
|
poolhandle_t (*Image_GetPool)( void );
|
||||||
const struct bpc_desc_s *(*Image_GetPFDesc)( int idx );
|
const struct bpc_desc_s *(*Image_GetPFDesc)( int idx );
|
||||||
|
|
||||||
// client exports
|
// client exports
|
||||||
|
|
|
@ -345,8 +345,8 @@ typedef struct
|
||||||
NEW_DLL_FUNCTIONS dllFuncs2; // new dll exported funcs (may be NULL)
|
NEW_DLL_FUNCTIONS dllFuncs2; // new dll exported funcs (may be NULL)
|
||||||
physics_interface_t physFuncs; // physics interface functions (Xash3D extension)
|
physics_interface_t physFuncs; // physics interface functions (Xash3D extension)
|
||||||
|
|
||||||
byte *mempool; // server premamnent pool: edicts etc
|
poolhandle_t mempool; // server premamnent pool: edicts etc
|
||||||
byte *stringspool; // for engine strings
|
poolhandle_t stringspool; // for engine strings
|
||||||
} svgame_static_t;
|
} svgame_static_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
|
|
@ -56,7 +56,7 @@ GNU General Public License for more details.
|
||||||
#define LM_SAMPLE_SIZE 16
|
#define LM_SAMPLE_SIZE 16
|
||||||
|
|
||||||
|
|
||||||
extern byte *r_temppool;
|
extern poolhandle_t r_temppool;
|
||||||
|
|
||||||
#define BLOCK_SIZE tr.block_size // lightmap blocksize
|
#define BLOCK_SIZE tr.block_size // lightmap blocksize
|
||||||
#define BLOCK_SIZE_DEFAULT 128 // for keep backward compatibility
|
#define BLOCK_SIZE_DEFAULT 128 // for keep backward compatibility
|
||||||
|
|
|
@ -49,7 +49,7 @@ cvar_t *tracergreen;
|
||||||
cvar_t *tracerblue;
|
cvar_t *tracerblue;
|
||||||
cvar_t *traceralpha;
|
cvar_t *traceralpha;
|
||||||
|
|
||||||
byte *r_temppool;
|
poolhandle_t r_temppool;
|
||||||
|
|
||||||
gl_globals_t tr;
|
gl_globals_t tr;
|
||||||
glconfig_t glConfig;
|
glconfig_t glConfig;
|
||||||
|
|
|
@ -1734,7 +1734,7 @@ extern decal_t gDecalPool[MAX_RENDER_DECALS];
|
||||||
struct vbo_static_s
|
struct vbo_static_s
|
||||||
{
|
{
|
||||||
// quickly free all allocations on map change
|
// quickly free all allocations on map change
|
||||||
byte *mempool;
|
poolhandle_t mempool;
|
||||||
|
|
||||||
// arays
|
// arays
|
||||||
vbodecaldata_t *decaldata; // array
|
vbodecaldata_t *decaldata; // array
|
||||||
|
|
|
@ -19,7 +19,7 @@ ref_api_t gEngfuncs;
|
||||||
ref_globals_t *gpGlobals;
|
ref_globals_t *gpGlobals;
|
||||||
gl_globals_t tr;
|
gl_globals_t tr;
|
||||||
ref_speeds_t r_stats;
|
ref_speeds_t r_stats;
|
||||||
byte *r_temppool;
|
poolhandle_t r_temppool;
|
||||||
cvar_t *gl_emboss_scale;
|
cvar_t *gl_emboss_scale;
|
||||||
cvar_t *r_norefresh;
|
cvar_t *r_norefresh;
|
||||||
cvar_t *vid_brightness;
|
cvar_t *vid_brightness;
|
||||||
|
|
|
@ -57,7 +57,7 @@ typedef int fixed16_t;
|
||||||
#define LM_SAMPLE_SIZE 16
|
#define LM_SAMPLE_SIZE 16
|
||||||
|
|
||||||
|
|
||||||
extern byte *r_temppool;
|
extern poolhandle_t r_temppool;
|
||||||
|
|
||||||
#define BLOCK_SIZE tr.block_size // lightmap blocksize
|
#define BLOCK_SIZE tr.block_size // lightmap blocksize
|
||||||
#define BLOCK_SIZE_DEFAULT 128 // for keep backward compatibility
|
#define BLOCK_SIZE_DEFAULT 128 // for keep backward compatibility
|
||||||
|
|
Loading…
Add table
Reference in a new issue