lfnetwork.com mark read register faq members calendar

Thread: G_Alloc()
Thread Tools Display Modes
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Old 09-19-2006, 03:48 AM   #1
razorace
Impressive, Terran!
 
razorace's Avatar
 
Join Date: May 2002
Posts: 9,187
G_Alloc()

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()?


---Jedi Guardian of the Newbie Questions
---Masters of the Force Team Leader / Creator
---Open Jedi Project Lead Moderator / Co-Founder
razorace is offline   you may: quote & reply,
Old 09-19-2006, 04: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,
Old 09-19-2006, 04:53 PM   #3
razorace
Impressive, Terran!
 
razorace's Avatar
 
Join Date: May 2002
Posts: 9,187
I suppose I could do that, but then I'd have to worry about properly deallociating the data. I suspect that Raven did it this way to simplify the process (not requiring dealloc) and to statically allociate the "dynamic" memory.


---Jedi Guardian of the Newbie Questions
---Masters of the Force Team Leader / Creator
---Open Jedi Project Lead Moderator / Co-Founder
razorace is offline   you may: quote & reply,
Old 09-19-2006, 05:30 PM   #4
ensiform
The Stig
 
ensiform's Avatar
 
Join Date: Nov 2004
Location: Sawtooth Cauldron
Posts: 1,241
Current Game: Borderlands 2
And what is wrong with having to dealloc the mem? Btw, that isn't what raven did that is old q3 code (G_Alloc)


iojamp project lead / coder
ensiform is offline   you may: quote & reply,
Old 09-19-2006, 05:43 PM   #5
dumbledore
Rookie
 
Join Date: Nov 2005
Posts: 85
well if you wanted G_Alloc() to be able to dealloc mem you'd have to do the same thing anyway :S
dumbledore is offline   you may: quote & reply,
Old 09-19-2006, 07:56 PM   #6
razorace
Impressive, Terran!
 
razorace's Avatar
 
Join Date: May 2002
Posts: 9,187
Well, crap. Poke holes in my logic then.

Actually I was interested to see if it was really nessicary to only allociate in the temp buffer in 32 char chunks. It seems silly to me since it's just a big array buffer anyway.


---Jedi Guardian of the Newbie Questions
---Masters of the Force Team Leader / Creator
---Open Jedi Project Lead Moderator / Co-Founder
razorace is offline   you may: quote & reply,
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Go Back   LucasForums > Network > JediKnight Series > Editing Central > JA Coding > G_Alloc()

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:14 AM.

LFNetwork, LLC ©2002-2011 - All rights reserved.
Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.