mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2024-11-10 07:21:58 +00:00
SV_SpawnServer: use malloc for sv.edicts, and only zero it as needed
Previously we were Hunk_Alloc'ing space for 8192 edicts (by default) which zeros all of that memory, this way we only use as much RAM as needed since the unuesd pages aren't dirtied git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@1286 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
b7a0540bdf
commit
ae8a4f82da
3 changed files with 4 additions and 2 deletions
|
@ -549,6 +549,7 @@ void Host_ClearMemory (void)
|
|||
/* host_hunklevel MUST be set at this point */
|
||||
Hunk_FreeToLowMark (host_hunklevel);
|
||||
cls.signon = 0;
|
||||
if (sv.edicts) free(sv.edicts); // ericw -- sv.edicts switched to use malloc()
|
||||
memset (&sv, 0, sizeof(sv));
|
||||
memset (&cl, 0, sizeof(cl));
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ edict_t *ED_Alloc (void)
|
|||
|
||||
sv.num_edicts++;
|
||||
e = EDICT_NUM(i);
|
||||
ED_ClearEdict (e);
|
||||
memset(e, 0, pr_edict_size); // ericw -- switched sv.edicts to malloc(), so we are accessing uninitialized memory and must fully zero it, not just ED_ClearEdict
|
||||
|
||||
return e;
|
||||
}
|
||||
|
|
|
@ -1332,7 +1332,7 @@ void SV_SpawnServer (const char *server)
|
|||
// allocate server memory
|
||||
/* Host_ClearMemory() called above already cleared the whole sv structure */
|
||||
sv.max_edicts = CLAMP (MIN_EDICTS,(int)max_edicts.value,MAX_EDICTS); //johnfitz -- max_edicts cvar
|
||||
sv.edicts = (edict_t *) Hunk_AllocName (sv.max_edicts*pr_edict_size, "edicts");
|
||||
sv.edicts = (edict_t *) malloc (sv.max_edicts*pr_edict_size); // ericw -- sv.edicts switched to use malloc()
|
||||
|
||||
sv.datagram.maxsize = sizeof(sv.datagram_buf);
|
||||
sv.datagram.cursize = 0;
|
||||
|
@ -1348,6 +1348,7 @@ void SV_SpawnServer (const char *server)
|
|||
|
||||
// leave slots at start for clients only
|
||||
sv.num_edicts = svs.maxclients+1;
|
||||
memset(sv.edicts, 0, sv.num_edicts*pr_edict_size); // ericw -- sv.edicts switched to use malloc()
|
||||
for (i=0 ; i<svs.maxclients ; i++)
|
||||
{
|
||||
ent = EDICT_NUM(i+1);
|
||||
|
|
Loading…
Reference in a new issue