1
0
Fork 0
forked from fte/fteqw

BZ_* no longer clears, qclib no longer assumes memalloc clears

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2952 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
TimeServ 2008-05-11 12:55:53 +00:00
parent ce5cb75832
commit 0739c739a6
4 changed files with 32 additions and 47 deletions

View file

@ -278,7 +278,7 @@ void *Z_Realloc(void *data, int newsize)
void *BZF_Malloc(int size) //BZ_Malloc but allowed to fail - like straight malloc.
{
return calloc(size, 1); // TODO: this should be malloc but some code still assumes this is an alias to Z_Malloc
return malloc(size, 1);
}
void *BZ_Malloc(int size) //Doesn't clear. The expectation is a large file, rather than sensative data structures.

View file

@ -10,7 +10,7 @@ void *PRHunkAlloc(progfuncs_t *progfuncs, int ammount)
{
prmemb_t *mem;
ammount = sizeof(prmemb_t)+((ammount + 3)&~3);
mem = memalloc(ammount);
mem = memalloc(ammount);
memset(mem, 0, ammount);
mem->prev = memb;
if (!memb)
@ -380,8 +380,9 @@ string_t PR_StringToProgs (progfuncs_t *progfuncs, char *str)
}
prinst->maxallocedstrings += 1024;
ntable = memalloc(sizeof(char*) * prinst->maxallocedstrings);
ntable = memalloc(sizeof(char*) * prinst->maxallocedstrings);
memcpy(ntable, prinst->allocedstrings, sizeof(char*) * prinst->numallocedstrings);
memset(ntable + prinst->numallocedstrings, 0, sizeof(char*) * prinst->maxallocedstrings - prinst->numallocedstrings);
prinst->numallocedstrings = prinst->maxallocedstrings;
if (prinst->allocedstrings)
memfree(prinst->allocedstrings);

View file

@ -71,6 +71,19 @@ void ED_ClearEdict (progfuncs_t *progfuncs, edictrun_t *e)
e->entnum = num;
}
edictrun_t *ED_AllocIntoTable (progfuncs_t *progfuncs, int num)
{
edictrun_t *e;
prinst->edicttable[num] = *(struct edict_s **)&e = (void*)memalloc(externs->edictsize);
memset(e, 0, externs->edictsize);
e->fields = PRAddressableAlloc(progfuncs, fields_size);
e->entnum = num;
ED_ClearEdict(progfuncs, e);
return e;
}
/*
=================
ED_Alloc
@ -95,13 +108,9 @@ struct edict_s *ED_Alloc (progfuncs_t *progfuncs)
if (!e || (e->isfree && ( e->freetime < 2 || *externs->gametime - e->freetime > 0.5 ) ))
{
if (!e)
{
prinst->edicttable[i] = *(struct edict_s **)&e = (void*)memalloc(externs->edictsize);
e->fields = PRAddressableAlloc(progfuncs, fields_size);
e->entnum = i;
}
ED_ClearEdict (progfuncs, e);
e = ED_AllocIntoTable(progfuncs, i);
else
ED_ClearEdict (progfuncs, e);
if (externs->entspawn)
externs->entspawn((struct edict_s *) e);
@ -119,13 +128,9 @@ struct edict_s *ED_Alloc (progfuncs_t *progfuncs)
if (!e || (e->isfree))
{
if (!e)
{
prinst->edicttable[i] = *(struct edict_s **)&e = (void*)memalloc(externs->edictsize);
e->fields = PRAddressableAlloc(progfuncs, fields_size);
e->entnum = i;
}
ED_ClearEdict (progfuncs, e);
e = ED_AllocIntoTable(progfuncs, i);
else
ED_ClearEdict (progfuncs, e);
if (externs->entspawn)
externs->entspawn((struct edict_s *) e);
@ -152,13 +157,9 @@ struct edict_s *ED_Alloc (progfuncs_t *progfuncs)
e = (edictrun_t*)EDICT_NUM(progfuncs, i);
if (!e)
{
prinst->edicttable[i] = *(struct edict_s **)&e = (void*)memalloc(externs->edictsize);
e->fields = PRAddressableAlloc(progfuncs, fields_size);
e->entnum = i;
}
ED_ClearEdict (progfuncs, e);
e = ED_AllocIntoTable(progfuncs, i);
else
ED_ClearEdict (progfuncs, e);
if (externs->entspawn)
externs->entspawn((struct edict_s *) e);
@ -1676,9 +1677,7 @@ int LoadEnts(progfuncs_t *progfuncs, char *file, float killonspawnflags)
if (!ed)
{
prinst->edicttable[num] = *(struct edict_s **)&ed = (void*)memalloc(externs->edictsize);
ed->fields = PRAddressableAlloc(progfuncs, fields_size);
ed->entnum = num;
ed = ED_AllocIntoTable(progfuncs, num);
ed->isfree = true;
}
}
@ -1698,10 +1697,7 @@ int LoadEnts(progfuncs_t *progfuncs, char *file, float killonspawnflags)
if (!ed)
{
Sys_Error("Edict was not allocated\n");
prinst->edicttable[num] = *(struct edict_s **)&ed = (void*)memalloc(externs->edictsize);
ed->fields = PRAddressableAlloc(progfuncs, fields_size);
ED_ClearEdict(progfuncs, ed);
ed->entnum = num;
ed = ED_AllocIntoTable(progfuncs, num);
}
}
ed->isfree = false;
@ -1792,10 +1788,7 @@ int LoadEnts(progfuncs_t *progfuncs, char *file, float killonspawnflags)
if (!ed)
{
prinst->edicttable[num] = *(struct edict_s **)&ed = (void*)memalloc(externs->edictsize);
ed->fields = PRAddressableAlloc(progfuncs, fields_size);
ED_ClearEdict(progfuncs, ed);
ed->entnum = num;
ed = ED_AllocIntoTable(progfuncs, num);
ed->isfree = true;
}
}
@ -1951,13 +1944,7 @@ int LoadEnts(progfuncs_t *progfuncs, char *file, float killonspawnflags)
{
ed = (edictrun_t *)EDICT_NUM(progfuncs, numents);
if (!ed)
{
prinst->edicttable[numents] = *(struct edict_s **)&ed = (void*)memalloc(externs->edictsize);
ed->fields = PRAddressableAlloc(progfuncs, fields_size);
ED_ClearEdict(progfuncs, ed);
ed->entnum = numents;
ed->isfree = true;
}
ed = ED_AllocIntoTable(progfuncs, numents);
sv_num_edicts = numents;
ed->isfree = false;
@ -1978,10 +1965,7 @@ int LoadEnts(progfuncs_t *progfuncs, char *file, float killonspawnflags)
if (!ed)
{
prinst->edicttable[num] = *(struct edict_s **)&ed = (void*)memalloc(externs->edictsize);
ed->fields = PRAddressableAlloc(progfuncs, fields_size);
ED_ClearEdict(progfuncs, ed);
ed->entnum = num;
ed = ED_AllocIntoTable(progfuncs, num);
ed->isfree = true;
}
}

View file

@ -173,7 +173,7 @@ void QC_InitShares(progfuncs_t *progfuncs)
if (!field) //don't make it so we will just need to remalloc everything
{
maxfields = 64;
field = memalloc(sizeof(fdef_t) * maxfields);
field = memalloc(sizeof(fdef_t) * maxfields);
}
numfields = 0;