From 2dfd6476565eae6c4d4e56e1d76e85a5191562ee Mon Sep 17 00:00:00 2001 From: Tyrann Date: Sun, 10 Sep 2006 17:38:32 +0930 Subject: [PATCH] [PATCH 5/9] qbsp: Replace new/delete with malloc/free There's a couple of usages outside of the AllocMem/FreeMem functions. Flag these as something to look at later. Signed-off-by: Tyrann --- qbsp/map.c | 3 +-- qbsp/solidbsp.c | 5 +++-- qbsp/util.c | 9 +++------ 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/qbsp/map.c b/qbsp/map.c index 91982d17..15828549 100644 --- a/qbsp/map.c +++ b/qbsp/map.c @@ -550,8 +550,7 @@ SetKeyValue(int iEntity, char *key, char *value) for (ep = map.rgEntities[iEntity].epairs; ep; ep = ep->next) if (!strcmp(ep->key, key)) { - delete ep->value; - + free(ep->value); /* FIXME */ ep->value = copystring(value); return; } diff --git a/qbsp/solidbsp.c b/qbsp/solidbsp.c index 4bd5de9b..514b8cea 100644 --- a/qbsp/solidbsp.c +++ b/qbsp/solidbsp.c @@ -18,7 +18,8 @@ See file, 'COPYING', for details. */ -// solidbsp.c + +#include #include "qbsp.h" @@ -492,7 +493,7 @@ LinkConvexFaces(surface_t *planelist, node_t *leafnode) // write the list of faces, and free the originals leaffaces += count; - leafnode->markfaces = (face_t **)new char[sizeof(face_t *) * (count + 1)]; + leafnode->markfaces = (face_t **)malloc(sizeof(face_t *) * (count + 1)); /* FIXME */ i = 0; for (surf = planelist; surf; surf = pnext) { diff --git a/qbsp/util.c b/qbsp/util.c index 338b2eea..0ef60fb3 100644 --- a/qbsp/util.c +++ b/qbsp/util.c @@ -30,7 +30,7 @@ #endif #include -//#include +#include #include "qbsp.h" @@ -68,7 +68,7 @@ AllocMem(int Type, int cElements, bool fZero) cSize = cElements * rgcMemSize[Type]; Retry: - pTemp = (void *)new char[cSize]; + pTemp = malloc(cSize); if (pTemp == NULL) { char ch; @@ -116,13 +116,10 @@ FreeMem void FreeMem(void *pMem, int Type, int cElements) { - char *mem; - rgMemActive[Type] -= cElements; rgMemActive[GLOBAL] -= cElements * rgcMemSize[Type]; - mem = (char *)pMem; - delete [] mem; + free(pMem); }