use Hunk_TempAlloc instead of realloc for the alias model verts

This commit is contained in:
Bill Currie 2002-01-07 16:43:47 +00:00
parent c1c76f7058
commit 9ba80eb4d9
2 changed files with 20 additions and 29 deletions

View file

@ -697,33 +697,29 @@ R_AliasSetupFrame (void)
((byte *) paliashdr + paliasgroup->frames[i].frame);
}
finalvert_t *finalverts;
auxvert_t *auxverts;
int maxaliasverts = 0;
void
R_AliasDrawModel (alight_t *plighting)
{
int size;
finalvert_t *finalverts;
r_amodels_drawn++;
paliashdr = Cache_Get (&currententity->model->cache);
pmdl = (mdl_t *) ((byte *) paliashdr + paliashdr->model);
if (pmdl->numverts > maxaliasverts)
{
finalverts = realloc (finalverts, (CACHE_SIZE - 1) +
sizeof (finalvert_t) * (pmdl->numverts + 1));
auxverts = realloc (auxverts,
sizeof (auxvert_t) * pmdl->numverts);
if (!finalverts || !auxverts)
Sys_Error ("R_AliasDrawModel: out of memory");
maxaliasverts = pmdl->numverts;
}
size = (CACHE_SIZE - 1)
+ sizeof (finalvert_t) * (pmdl->numverts + 1)
+ sizeof (auxvert_t) * pmdl->numverts;
finalverts = (finalvert_t *) Hunk_TempAlloc (size);
if (!finalverts)
Sys_Error ("R_AliasDrawModel: out of memory");
// cache align
pfinalverts = (finalvert_t *)
(((long) &finalverts[0] + CACHE_SIZE - 1) & ~(CACHE_SIZE - 1));
pauxverts = &auxverts[0];
pauxverts = (auxvert_t *) &pfinalverts[pmdl->numverts + 1];
R_AliasSetupSkin ();
R_AliasSetUpTransform (currententity->trivial_accept);

View file

@ -688,33 +688,28 @@ R_AliasSetupFrame (void)
}
finalvert_t *finalverts;
auxvert_t *auxverts;
int maxaliasverts = 0;
void
R_AliasDrawModel (alight_t *plighting)
{
int size;
finalvert_t *finalverts;
r_amodels_drawn++;
paliashdr = Cache_Get (&currententity->model->cache);
pmdl = (mdl_t *) ((byte *) paliashdr + paliashdr->model);
if (pmdl->numverts > maxaliasverts)
{
finalverts = realloc (finalverts, (CACHE_SIZE - 1) +
sizeof (finalvert_t) * (pmdl->numverts + 1));
auxverts = realloc (auxverts,
sizeof (auxvert_t) * pmdl->numverts);
if (!finalverts || !auxverts)
Sys_Error ("R_AliasDrawModel: out of memory");
maxaliasverts = pmdl->numverts;
}
size = (CACHE_SIZE - 1)
+ sizeof (finalvert_t) * (pmdl->numverts + 1)
+ sizeof (auxvert_t) * pmdl->numverts;
finalverts = (finalvert_t *) Hunk_TempAlloc (size);
if (!finalverts)
Sys_Error ("R_AliasDrawModel: out of memory");
// cache align
pfinalverts = (finalvert_t *)
(((long) &finalverts[0] + CACHE_SIZE - 1) & ~(CACHE_SIZE - 1));
pauxverts = &auxverts[0];
pauxverts = (auxvert_t *) &pfinalverts[pmdl->numverts + 1];
R_AliasSetupSkin ();
R_AliasSetUpTransform (currententity->trivial_accept);