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.
|
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.
|
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;
|
prinst->maxallocedstrings += 1024;
|
||||||
ntable = memalloc(sizeof(char*) * prinst->maxallocedstrings);
|
ntable = memalloc(sizeof(char*) * prinst->maxallocedstrings);
|
||||||
memcpy(ntable, prinst->allocedstrings, sizeof(char*) * prinst->numallocedstrings);
|
memcpy(ntable, prinst->allocedstrings, sizeof(char*) * prinst->numallocedstrings);
|
||||||
|
memset(ntable + prinst->numallocedstrings, 0, sizeof(char*) * prinst->maxallocedstrings - prinst->numallocedstrings);
|
||||||
prinst->numallocedstrings = prinst->maxallocedstrings;
|
prinst->numallocedstrings = prinst->maxallocedstrings;
|
||||||
if (prinst->allocedstrings)
|
if (prinst->allocedstrings)
|
||||||
memfree(prinst->allocedstrings);
|
memfree(prinst->allocedstrings);
|
||||||
|
|
|
@ -71,6 +71,19 @@ void ED_ClearEdict (progfuncs_t *progfuncs, edictrun_t *e)
|
||||||
e->entnum = num;
|
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
|
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 || (e->isfree && ( e->freetime < 2 || *externs->gametime - e->freetime > 0.5 ) ))
|
||||||
{
|
{
|
||||||
if (!e)
|
if (!e)
|
||||||
{
|
e = ED_AllocIntoTable(progfuncs, i);
|
||||||
prinst->edicttable[i] = *(struct edict_s **)&e = (void*)memalloc(externs->edictsize);
|
else
|
||||||
e->fields = PRAddressableAlloc(progfuncs, fields_size);
|
ED_ClearEdict (progfuncs, e);
|
||||||
e->entnum = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
ED_ClearEdict (progfuncs, e);
|
|
||||||
|
|
||||||
if (externs->entspawn)
|
if (externs->entspawn)
|
||||||
externs->entspawn((struct edict_s *) e);
|
externs->entspawn((struct edict_s *) e);
|
||||||
|
@ -119,13 +128,9 @@ struct edict_s *ED_Alloc (progfuncs_t *progfuncs)
|
||||||
if (!e || (e->isfree))
|
if (!e || (e->isfree))
|
||||||
{
|
{
|
||||||
if (!e)
|
if (!e)
|
||||||
{
|
e = ED_AllocIntoTable(progfuncs, i);
|
||||||
prinst->edicttable[i] = *(struct edict_s **)&e = (void*)memalloc(externs->edictsize);
|
else
|
||||||
e->fields = PRAddressableAlloc(progfuncs, fields_size);
|
ED_ClearEdict (progfuncs, e);
|
||||||
e->entnum = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
ED_ClearEdict (progfuncs, e);
|
|
||||||
|
|
||||||
if (externs->entspawn)
|
if (externs->entspawn)
|
||||||
externs->entspawn((struct edict_s *) e);
|
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);
|
e = (edictrun_t*)EDICT_NUM(progfuncs, i);
|
||||||
|
|
||||||
if (!e)
|
if (!e)
|
||||||
{
|
e = ED_AllocIntoTable(progfuncs, i);
|
||||||
prinst->edicttable[i] = *(struct edict_s **)&e = (void*)memalloc(externs->edictsize);
|
else
|
||||||
e->fields = PRAddressableAlloc(progfuncs, fields_size);
|
ED_ClearEdict (progfuncs, e);
|
||||||
e->entnum = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
ED_ClearEdict (progfuncs, e);
|
|
||||||
|
|
||||||
if (externs->entspawn)
|
if (externs->entspawn)
|
||||||
externs->entspawn((struct edict_s *) e);
|
externs->entspawn((struct edict_s *) e);
|
||||||
|
@ -1676,9 +1677,7 @@ int LoadEnts(progfuncs_t *progfuncs, char *file, float killonspawnflags)
|
||||||
|
|
||||||
if (!ed)
|
if (!ed)
|
||||||
{
|
{
|
||||||
prinst->edicttable[num] = *(struct edict_s **)&ed = (void*)memalloc(externs->edictsize);
|
ed = ED_AllocIntoTable(progfuncs, num);
|
||||||
ed->fields = PRAddressableAlloc(progfuncs, fields_size);
|
|
||||||
ed->entnum = num;
|
|
||||||
ed->isfree = true;
|
ed->isfree = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1698,10 +1697,7 @@ int LoadEnts(progfuncs_t *progfuncs, char *file, float killonspawnflags)
|
||||||
if (!ed)
|
if (!ed)
|
||||||
{
|
{
|
||||||
Sys_Error("Edict was not allocated\n");
|
Sys_Error("Edict was not allocated\n");
|
||||||
prinst->edicttable[num] = *(struct edict_s **)&ed = (void*)memalloc(externs->edictsize);
|
ed = ED_AllocIntoTable(progfuncs, num);
|
||||||
ed->fields = PRAddressableAlloc(progfuncs, fields_size);
|
|
||||||
ED_ClearEdict(progfuncs, ed);
|
|
||||||
ed->entnum = num;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ed->isfree = false;
|
ed->isfree = false;
|
||||||
|
@ -1792,10 +1788,7 @@ int LoadEnts(progfuncs_t *progfuncs, char *file, float killonspawnflags)
|
||||||
|
|
||||||
if (!ed)
|
if (!ed)
|
||||||
{
|
{
|
||||||
prinst->edicttable[num] = *(struct edict_s **)&ed = (void*)memalloc(externs->edictsize);
|
ed = ED_AllocIntoTable(progfuncs, num);
|
||||||
ed->fields = PRAddressableAlloc(progfuncs, fields_size);
|
|
||||||
ED_ClearEdict(progfuncs, ed);
|
|
||||||
ed->entnum = num;
|
|
||||||
ed->isfree = true;
|
ed->isfree = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1951,13 +1944,7 @@ int LoadEnts(progfuncs_t *progfuncs, char *file, float killonspawnflags)
|
||||||
{
|
{
|
||||||
ed = (edictrun_t *)EDICT_NUM(progfuncs, numents);
|
ed = (edictrun_t *)EDICT_NUM(progfuncs, numents);
|
||||||
if (!ed)
|
if (!ed)
|
||||||
{
|
ed = ED_AllocIntoTable(progfuncs, numents);
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
sv_num_edicts = numents;
|
sv_num_edicts = numents;
|
||||||
ed->isfree = false;
|
ed->isfree = false;
|
||||||
|
@ -1978,10 +1965,7 @@ int LoadEnts(progfuncs_t *progfuncs, char *file, float killonspawnflags)
|
||||||
|
|
||||||
if (!ed)
|
if (!ed)
|
||||||
{
|
{
|
||||||
prinst->edicttable[num] = *(struct edict_s **)&ed = (void*)memalloc(externs->edictsize);
|
ed = ED_AllocIntoTable(progfuncs, num);
|
||||||
ed->fields = PRAddressableAlloc(progfuncs, fields_size);
|
|
||||||
ED_ClearEdict(progfuncs, ed);
|
|
||||||
ed->entnum = num;
|
|
||||||
ed->isfree = true;
|
ed->isfree = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue