From 38d82d77136be9239dba3d50889ff99db412001a Mon Sep 17 00:00:00 2001 From: meep-eep Date: Mon, 27 Jan 2003 02:12:32 +0000 Subject: [PATCH] Replaced some malloc() calls to HMalloc. Similar for free() and realloc(). mem_init() is now called earlier in the main loop. git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@587 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/src/sc2code/libs/file/dirs.c | 5 +++-- sc2/src/sc2code/libs/file/temp.c | 5 +++-- sc2/src/starcon2.c | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/sc2/src/sc2code/libs/file/dirs.c b/sc2/src/sc2code/libs/file/dirs.c index f24995fc4..028fa3b1a 100644 --- a/sc2/src/sc2code/libs/file/dirs.c +++ b/sc2/src/sc2code/libs/file/dirs.c @@ -25,6 +25,7 @@ #include "config.h" #include "filintrn.h" #include "compiler.h" +#include "misc.h" #ifdef WIN32 # include @@ -228,11 +229,11 @@ expandPath (char *dest, size_t len, const char *src) } envNameLen = end - src; - envName = malloc (envNameLen + 1); + envName = HMalloc (envNameLen + 1); memcpy (envName, src, envNameLen + 1); envName[envNameLen] = '\0'; envVar = getenv (envName); - free (envName); + HFree (envName); if (envVar == NULL) { diff --git a/sc2/src/sc2code/libs/file/temp.c b/sc2/src/sc2code/libs/file/temp.c index 4d46f4546..bf71b1672 100644 --- a/sc2/src/sc2code/libs/file/temp.c +++ b/sc2/src/sc2code/libs/file/temp.c @@ -28,6 +28,7 @@ #include "timelib.h" #include "port.h" #include "libs/compiler.h" +#include "misc.h" static char *tempDir; @@ -97,7 +98,7 @@ initTempDir (void) { // Pointer to the location in the tempDir string where the // path to the temp dir ends and the dir starts. - tempDir = malloc (PATH_MAX); + tempDir = HMalloc (PATH_MAX); getTempDir (tempDir, PATH_MAX - 21); // reserve 8 chars for dirname, 1 for slash, and 12 for filename len = strlen(tempDir); @@ -113,7 +114,7 @@ initTempDir (void) { continue; // Success, we've got a temp dir. - tempDir = realloc (tempDir, len + 9); + tempDir = HRealloc (tempDir, len + 9); atexit (removeTempDir); return; } diff --git a/sc2/src/starcon2.c b/sc2/src/starcon2.c index cec36d6ad..199c98500 100644 --- a/sc2/src/starcon2.c +++ b/sc2/src/starcon2.c @@ -258,6 +258,8 @@ main (int argc, char *argv[]) } } + mem_init (); + initTempDir(); CDToContentDir (contentdir); prepareConfigDir(); @@ -268,7 +270,6 @@ main (int argc, char *argv[]) InitTimeSystem (); InitTaskSystem (); - mem_init (); GraphicsSem = CreateSemaphore (1, "Graphics"); RenderingCond = CreateCondVar (); init_xform_control ();