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
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "filintrn.h"
|
#include "filintrn.h"
|
||||||
#include "compiler.h"
|
#include "compiler.h"
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
# include <direct.h>
|
# include <direct.h>
|
||||||
@@ -228,11 +229,11 @@ expandPath (char *dest, size_t len, const char *src)
|
|||||||
}
|
}
|
||||||
|
|
||||||
envNameLen = end - src;
|
envNameLen = end - src;
|
||||||
envName = malloc (envNameLen + 1);
|
envName = HMalloc (envNameLen + 1);
|
||||||
memcpy (envName, src, envNameLen + 1);
|
memcpy (envName, src, envNameLen + 1);
|
||||||
envName[envNameLen] = '\0';
|
envName[envNameLen] = '\0';
|
||||||
envVar = getenv (envName);
|
envVar = getenv (envName);
|
||||||
free (envName);
|
HFree (envName);
|
||||||
|
|
||||||
if (envVar == NULL)
|
if (envVar == NULL)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include "timelib.h"
|
#include "timelib.h"
|
||||||
#include "port.h"
|
#include "port.h"
|
||||||
#include "libs/compiler.h"
|
#include "libs/compiler.h"
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
static char *tempDir;
|
static char *tempDir;
|
||||||
|
|
||||||
@@ -97,7 +98,7 @@ initTempDir (void) {
|
|||||||
// Pointer to the location in the tempDir string where the
|
// Pointer to the location in the tempDir string where the
|
||||||
// path to the temp dir ends and the dir starts.
|
// path to the temp dir ends and the dir starts.
|
||||||
|
|
||||||
tempDir = malloc (PATH_MAX);
|
tempDir = HMalloc (PATH_MAX);
|
||||||
getTempDir (tempDir, PATH_MAX - 21);
|
getTempDir (tempDir, PATH_MAX - 21);
|
||||||
// reserve 8 chars for dirname, 1 for slash, and 12 for filename
|
// reserve 8 chars for dirname, 1 for slash, and 12 for filename
|
||||||
len = strlen(tempDir);
|
len = strlen(tempDir);
|
||||||
@@ -113,7 +114,7 @@ initTempDir (void) {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Success, we've got a temp dir.
|
// Success, we've got a temp dir.
|
||||||
tempDir = realloc (tempDir, len + 9);
|
tempDir = HRealloc (tempDir, len + 9);
|
||||||
atexit (removeTempDir);
|
atexit (removeTempDir);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -258,6 +258,8 @@ main (int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mem_init ();
|
||||||
|
|
||||||
initTempDir();
|
initTempDir();
|
||||||
CDToContentDir (contentdir);
|
CDToContentDir (contentdir);
|
||||||
prepareConfigDir();
|
prepareConfigDir();
|
||||||
@@ -268,7 +270,6 @@ main (int argc, char *argv[])
|
|||||||
InitTimeSystem ();
|
InitTimeSystem ();
|
||||||
InitTaskSystem ();
|
InitTaskSystem ();
|
||||||
|
|
||||||
mem_init ();
|
|
||||||
GraphicsSem = CreateSemaphore (1, "Graphics");
|
GraphicsSem = CreateSemaphore (1, "Graphics");
|
||||||
RenderingCond = CreateCondVar ();
|
RenderingCond = CreateCondVar ();
|
||||||
init_xform_control ();
|
init_xform_control ();
|
||||||
|
|||||||
Reference in New Issue
Block a user