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:
parent
ce5cb75832
commit
0739c739a6
4 changed files with 32 additions and 47 deletions
|
@ -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.
|
||||
|
|
|
@ -382,6 +382,7 @@ string_t PR_StringToProgs (progfuncs_t *progfuncs, char *str)
|
|||
prinst->maxallocedstrings += 1024;
|
||||
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);
|
||||
|
|
|
@ -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,12 +108,8 @@ 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;
|
||||
}
|
||||
|
||||
e = ED_AllocIntoTable(progfuncs, i);
|
||||
else
|
||||
ED_ClearEdict (progfuncs, e);
|
||||
|
||||
if (externs->entspawn)
|
||||
|
@ -119,12 +128,8 @@ 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;
|
||||
}
|
||||
|
||||
e = ED_AllocIntoTable(progfuncs, i);
|
||||
else
|
||||
ED_ClearEdict (progfuncs, e);
|
||||
|
||||
if (externs->entspawn)
|
||||
|
@ -152,12 +157,8 @@ 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;
|
||||
}
|
||||
|
||||
e = ED_AllocIntoTable(progfuncs, i);
|
||||
else
|
||||
ED_ClearEdict (progfuncs, e);
|
||||
|
||||
if (externs->entspawn)
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue