Jump to content

Home

G_Alloc()


razorace

Recommended Posts

As part of the my CoOp work, I've come across a problem with G_Alloc running out of space. Well, I looked at the actual function and it seems a bit inefficent. It only allocates in 32 char chunks and never allows for deallocation.

 

Does anyone know of a more efficent way to do G_Alloc()?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...