Thread: G_Alloc()
View Single Post
Old 09-19-2006, 03:04 PM   #2
ensiform
The Stig
 
ensiform's Avatar
 
Join Date: Nov 2004
Location: Sawtooth Cauldron
Posts: 1,241
Current Game: Borderlands 2
I would try using trap_TrueMalloc and trap_TrueFree, best methods that I know of. And can be used from all of the modules.

trap_TrueMalloc example:

g_sess is clientSession * and trueMalloc wants the first arg to be a void **, second arg is the size you wish to alloc.

trap_TrueMalloc( (void **)&g_sess, g_maxclients.integer * sizeof( clientSession_t ) );

trap_TrueFree example:

argument is the pointer you are freeing from truemalloc and again wants **

trap_TrueFree( (void **)&g_sess );

you really do not need (void **) but gcc likes to be picky about those kinds of things.


iojamp project lead / coder
ensiform is offline   you may: quote & reply,