Get rid of FreeTemporary. NFC.

Its only use was in a context where it was completely equivalent to
MemFree, so just use that instead, and keep the temporary heap as
purely an arena allocator, that could use something like bump
pointer.
pull/434/head
whitequark 2019-05-23 19:23:40 +00:00
parent ac7b82d7c1
commit fabffbab79
4 changed files with 4 additions and 20 deletions

View File

@ -110,11 +110,11 @@ void SMesh::Simplify(int start) {
STriMeta meta = l.elem[start].meta;
STriangle *tout = (STriangle *)AllocTemporary(maxTriangles*sizeof(*tout));
STriangle *tout = (STriangle *)MemAlloc(maxTriangles*sizeof(*tout));
int toutc = 0;
Vector n = Vector::From(0, 0, 0);
Vector *conv = (Vector *)AllocTemporary(maxTriangles*3*sizeof(*conv));
Vector *conv = (Vector *)MemAlloc(maxTriangles*3*sizeof(*conv));
int convc = 0;
int start0 = start;
@ -236,8 +236,8 @@ void SMesh::Simplify(int start) {
for(i = 0; i < toutc; i++) {
AddTriangle(&(tout[i]));
}
FreeTemporary(tout);
FreeTemporary(conv);
MemFree(tout);
MemFree(conv);
}
void SMesh::AddAgainstBsp(SMesh *srcm, SBsp3 *bsp3) {

View File

@ -54,18 +54,6 @@ void *AllocTemporary(size_t n)
return (void *)&h[1];
}
void FreeTemporary(void *p)
{
AllocTempHeader *h = (AllocTempHeader *)p - 1;
if(h->prev) {
h->prev->next = h->next;
} else {
Head = h->next;
}
if(h->next) h->next->prev = h->prev;
free(h);
}
void FreeAllTemporary(void)
{
AllocTempHeader *h = Head;

View File

@ -47,9 +47,6 @@ void *AllocTemporary(size_t n)
ssassert(v != NULL, "Cannot allocate memory");
return v;
}
void FreeTemporary(void *p) {
HeapFree(TempHeap, HEAP_NO_SERIALIZE, p);
}
void FreeAllTemporary()
{
if(TempHeap) HeapDestroy(TempHeap);

View File

@ -150,7 +150,6 @@ void dbp(const char *str, ...);
std::vector<std::string> InitPlatform(int argc, char **argv);
void *AllocTemporary(size_t n);
void FreeTemporary(void *p);
void FreeAllTemporary();
void *MemAlloc(size_t n);
void MemFree(void *p);