Commit deb8f0f6 authored by Richard Gobeille's avatar Richard Gobeille

engine/all: allocation fixes WIP

parent b91898fc
......@@ -833,7 +833,7 @@ int MV_Init(int soundcard, int MixRate, int Voices, int numchannels, void *initd
MV_Voices->Init();
LL::Reset((VoiceNode*) &VoiceList);
MV_Handles = (VoiceNode **)Bcalloc(Voices, sizeof(intptr_t));
MV_Handles = (VoiceNode **)Xcalloc(Voices, sizeof(intptr_t));
#ifdef ASS_REVERSESTEREO
MV_SetReverseStereo(FALSE);
#endif
......
......@@ -942,13 +942,13 @@ static void *setup_malloc(vorb *f, int sz)
f->setup_offset += sz;
return p;
}
return sz ? Bmalloc(sz) : NULL;
return sz ? Xmalloc(sz) : NULL;
}
static void setup_free(vorb *f, void *p)
{
if (f->alloc.alloc_buffer) return; // do nothing; setup mem is a stack
Bfree(p);
Xfree(p);
}
static void *setup_temp_malloc(vorb *f, int sz)
......@@ -959,7 +959,7 @@ static void *setup_temp_malloc(vorb *f, int sz)
f->temp_offset -= sz;
return (char *) f->alloc.alloc_buffer + f->temp_offset;
}
return Bmalloc(sz);
return Xmalloc(sz);
}
static void setup_temp_free(vorb *f, void *p, int sz)
......@@ -968,7 +968,7 @@ static void setup_temp_free(vorb *f, void *p, int sz)
f->temp_offset += (sz+7)&~7;
return;
}
Bfree(p);
Xfree(p);
}
#define CRC32_POLY 0x04c11db7 // from spec
......@@ -5337,7 +5337,7 @@ int stb_vorbis_decode_filename(const char *filename, int *channels, int *sample_
*sample_rate = v->sample_rate;
offset = data_len = 0;
total = limit;
data = (short *) Bmalloc(total * sizeof(*data));
data = (short *) Xmalloc(total * sizeof(*data));
if (data == NULL) {
stb_vorbis_close(v);
return -2;
......@@ -5350,9 +5350,9 @@ int stb_vorbis_decode_filename(const char *filename, int *channels, int *sample_
if (offset + limit > total) {
short *data2;
total *= 2;
data2 = (short *) Brealloc(data, total * sizeof(*data));
data2 = (short *) Xrealloc(data, total * sizeof(*data));
if (data2 == NULL) {
Bfree(data);
Xfree(data);
stb_vorbis_close(v);
return -2;
}
......@@ -5377,7 +5377,7 @@ int stb_vorbis_decode_memory(const uint8 *mem, int len, int *channels, int *samp
*sample_rate = v->sample_rate;
offset = data_len = 0;
total = limit;
data = (short *) Bmalloc(total * sizeof(*data));
data = (short *) Xmalloc(total * sizeof(*data));
if (data == NULL) {
stb_vorbis_close(v);
return -2;
......@@ -5390,9 +5390,9 @@ int stb_vorbis_decode_memory(const uint8 *mem, int len, int *channels, int *samp
if (offset + limit > total) {
short *data2;
total *= 2;
data2 = (short *) Brealloc(data, total * sizeof(*data));
data2 = (short *) Xrealloc(data, total * sizeof(*data));
if (data2 == NULL) {
Bfree(data);
Xfree(data);
stb_vorbis_close(v);
return -2;
}
......
......@@ -50,7 +50,7 @@ struct GrowArray
{
size_ = 0;
capacity_ = 0;
Bfree(data_);
Xfree(data_);
data_ = nullptr;
}
......
......@@ -943,9 +943,52 @@ struct bad_arg_to_ARRAY_SIZE
////////// Memory management //////////
static FORCE_INLINE void *Baligned_alloc(const size_t alignment, const size_t size)
{
# ifdef _WIN32
return _aligned_malloc(size, alignment);
# elif defined __APPLE__ || defined EDUKE32_BSD
void *ptr = NULL;
posix_memalign(&ptr, alignment, size);
return ptr;
# else
return aligned_alloc(alignment, size);
# endif
}
static FORCE_INLINE void *Baligned_realloc(void *oldptr, const size_t alignment, const size_t size)
{
# ifdef _WIN32
return _aligned_realloc(oldptr, size, alignment);
# elif defined __APPLE__ || defined EDUKE32_BSD
void *ptr = NULL;
posix_memalign(&ptr, alignment, size);
Bmemcpy(ptr, oldptr, _msize(oldptr));
return ptr;
# else
void *ptr = aligned_alloc(alignment, size);
Bmemcpy(ptr, oldptr, _msize(oldptr));
return ptr;
# endif
}
#define Baligned_free Xfree
#ifdef DEBUGGINGAIDS
extern void xalloc_set_location(int32_t line, const char *file, const char *func);
#endif
extern const char *g_MemErrFunc;
extern const char *g_MemErrFile;
extern int32_t g_MemErrLine;
static FORCE_INLINE void xalloc_set_location(int32_t const line, const char * const file, const char * const func)
{
g_MemErrLine = line;
g_MemErrFile = file;
if (func)
g_MemErrFunc = func;
}
#endif
void set_memerr_handler(void (*handlerfunc)(int32_t, const char *, const char *));
void *handle_memerr(void);
......@@ -966,13 +1009,17 @@ static FORCE_INLINE char *xstrdup(const char *s)
char *ptr = (char *)_sm_malloc(g_sm_heap, len, ALLOC_ALIGNMENT);
Bstrcpy(ptr, s);
ptr[len-1] = '\0';
return (EDUKE32_PREDICT_TRUE(ptr != NULL)) ? ptr : (char *)handle_memerr();
if (EDUKE32_PREDICT_TRUE(ptr != nullptr)) return ptr;
handle_memerr();
EDUKE32_UNREACHABLE_SECTION(return nullptr);
}
static FORCE_INLINE void *xmalloc(bsize_t const size)
{
void *ptr = _sm_malloc(g_sm_heap, size, ALLOC_ALIGNMENT);
return (EDUKE32_PREDICT_TRUE(ptr != NULL)) ? ptr : handle_memerr();
if (EDUKE32_PREDICT_TRUE(ptr != nullptr)) return ptr;
handle_memerr();
EDUKE32_UNREACHABLE_SECTION(return nullptr);
}
static FORCE_INLINE void *xcalloc(bsize_t const nmemb, bsize_t const size)
......@@ -980,7 +1027,9 @@ static FORCE_INLINE void *xcalloc(bsize_t const nmemb, bsize_t const size)
bsize_t const siz = nmemb * size;
void *ptr = _sm_malloc(g_sm_heap, siz, ALLOC_ALIGNMENT);
Bmemset(ptr, 0, siz);
return (EDUKE32_PREDICT_TRUE(ptr != NULL)) ? ptr : handle_memerr();
if (EDUKE32_PREDICT_TRUE(ptr != nullptr)) return ptr;
handle_memerr();
EDUKE32_UNREACHABLE_SECTION(return nullptr);
}
static FORCE_INLINE void *xrealloc(void * const ptr, bsize_t const size)
......@@ -991,7 +1040,9 @@ static FORCE_INLINE void *xrealloc(void * const ptr, bsize_t const size)
// - ptr == NULL makes realloc() behave like malloc()
// - size == 0 make it behave like free() if ptr != NULL
// Since we want to catch an out-of-mem in the first case, this leaves:
return (EDUKE32_PREDICT_TRUE(newptr != NULL || size == 0)) ? newptr: handle_memerr();
if (EDUKE32_PREDICT_TRUE(newptr != nullptr || size == 0)) return newptr;
handle_memerr();
EDUKE32_UNREACHABLE_SECTION(return nullptr);
}
#undef ALLOC_ALIGNMENT
......@@ -999,19 +1050,22 @@ static FORCE_INLINE void *xrealloc(void * const ptr, bsize_t const size)
static FORCE_INLINE void *xaligned_alloc(bsize_t const alignment, bsize_t const size)
{
void *ptr = _sm_malloc(g_sm_heap, size, alignment);
return (EDUKE32_PREDICT_TRUE(ptr != NULL)) ? ptr : handle_memerr();
if (EDUKE32_PREDICT_TRUE(ptr != nullptr)) return ptr;
handle_memerr();
EDUKE32_UNREACHABLE_SECTION(return nullptr);
}
static FORCE_INLINE void *xaligned_calloc(bsize_t const alignment, bsize_t const count, bsize_t const size)
{
bsize_t const blocksize = count * size;
void *ptr = _sm_malloc(g_sm_heap, blocksize, alignment);
if (EDUKE32_PREDICT_TRUE(ptr != NULL))
if (EDUKE32_PREDICT_TRUE(ptr != nullptr))
{
Bmemset(ptr, 0, blocksize);
return ptr;
}
return handle_memerr();
handle_memerr();
EDUKE32_UNREACHABLE_SECTION(return nullptr);
}
#define Xstrdup(s) (EDUKE32_ALLOC_PREAMBLE xstrdup(s))
......@@ -1047,28 +1101,18 @@ void Cxfree(void * const ptr);
# define EDUKE32_ALLOC_PREAMBLE
#endif
#define Bstrdup Xstrdup
#define Bmalloc Xmalloc
#define Bcalloc Xcalloc
#define Brealloc Xrealloc
#define Baligned_alloc Xaligned_alloc
#define Baligned_calloc Xaligned_calloc
#define Bfree Xfree
#define Baligned_free Xaligned_free
////////// Pointer management //////////
#define DO_FREE_AND_NULL(var) do { \
Bfree(var); (var) = NULL; \
Xfree(var); (var) = nullptr; \
} while (0)
#define ALIGNED_FREE_AND_NULL(var) do { \
Baligned_free(var); (var) = NULL; \
Baligned_free(var); (var) = nullptr; \
} while (0)
#define DO_DELETE_AND_NULL(var) do { \
delete (var); (var) = NULL; \
delete (var); (var) = nullptr; \
} while (0)
......@@ -1428,7 +1472,7 @@ static inline void maybe_grow_buffer(char ** const buffer, int32_t * const buffe
{
if (newsize > *buffersize)
{
*buffer = (char *)Brealloc(*buffer, newsize);
*buffer = (char *)Xrealloc(*buffer, newsize);
*buffersize = newsize;
}
}
......
......@@ -53,9 +53,9 @@ typedef struct mz_dummy_time_t_tag
#define MZ_FREE(x) (void)x, ((void)0)
#define MZ_REALLOC(p, x) NULL
#else
#define MZ_MALLOC(x) Bmalloc(x)
#define MZ_FREE(x) Bfree(x)
#define MZ_REALLOC(p, x) Brealloc(p, x)
#define MZ_MALLOC(x) Xmalloc(x)
#define MZ_FREE(x) Xfree(x)
#define MZ_REALLOC(p, x) Xrealloc(p, x)
#endif
#define MZ_MAX(a, b) (((a) > (b)) ? (a) : (b))
......
......@@ -324,9 +324,9 @@ bool sjson_check(const sjson_node* node, char errmsg[256]);
#ifndef sjson_malloc
# include <stdlib.h>
# include <string.h>
# define sjson_malloc(user, size) ((UNREFERENCED_PARAMETER(user)), Bmalloc(size))
# define sjson_free(user, ptr) ((UNREFERENCED_PARAMETER(user)), Bfree(ptr))
# define sjson_realloc(user, ptr, size) ((UNREFERENCED_PARAMETER(user)), Brealloc(ptr, size))
# define sjson_malloc(user, size) ((UNREFERENCED_PARAMETER(user)), Xmalloc(size))
# define sjson_free(user, ptr) ((UNREFERENCED_PARAMETER(user)), Xfree(ptr))
# define sjson_realloc(user, ptr, size) ((UNREFERENCED_PARAMETER(user)), Xrealloc(ptr, size))
#endif
#ifndef sjson_assert
......
......@@ -753,7 +753,7 @@ int app_main(int argc, char const * const * argv)
initprintf("Definitions file \"%s\" loaded.\n",defsfile);
for (char * m : g_defModules)
Bfree(m);
Xfree(m);
g_defModules.clear();
if (enginePostInit())
......@@ -803,7 +803,7 @@ int app_main(int argc, char const * const * argv)
initprintf("There was an error loading the sprite clipping map (status %d).\n", k);
for (char * f : g_clipMapFiles)
Bfree(f);
Xfree(f);
g_clipMapFiles.clear();
#endif
......
......@@ -37,18 +37,9 @@
static void (*g_MemErrHandler)(int32_t line, const char *file, const char *func);
#ifdef DEBUGGINGAIDS
static const char *g_MemErrFunc = "???";
static const char *g_MemErrFile = "???";
static int32_t g_MemErrLine;
void xalloc_set_location(int32_t line, const char *file, const char *func)
{
g_MemErrLine = line;
g_MemErrFile = file;
if (func)
g_MemErrFunc = func;
}
const char *g_MemErrFunc = "???";
const char *g_MemErrFile = "???";
int32_t g_MemErrLine;
#endif
void *handle_memerr(void)
......@@ -65,7 +56,7 @@ void *handle_memerr(void)
}
Bexit(EXIT_FAILURE);
EDUKE32_UNREACHABLE_SECTION(return &handle_memerr);
EDUKE32_UNREACHABLE_SECTION(return nullptr);
}
void set_memerr_handler(void (*handlerfunc)(int32_t, const char *, const char *)) { g_MemErrHandler = handlerfunc; }
......@@ -78,7 +69,7 @@ extern "C"
void *Cxrealloc(void *const ptr, bsize_t const size) { return xrealloc(ptr, size); }
void *Cxaligned_alloc(bsize_t const alignment, bsize_t const size) { return xaligned_alloc(alignment, size); }
void *Cxaligned_calloc(bsize_t const alignment, bsize_t const count, bsize_t const size) { return xaligned_calloc(alignment, count, size); }
void Cxfree(void *const ptr) { Bfree(ptr); }
void Cxfree(void *const ptr) { Xfree(ptr); }
}
//
......@@ -110,7 +101,7 @@ char *Bgethomedir(void)
{
if (loaded)
FreeLibrary(hShell32);
return Bstrdup(appdata);
return Xstrdup(appdata);
}
}
......@@ -126,11 +117,11 @@ char *Bgethomedir(void)
drv = strchr(cwd, ':');
if (drv)
drv[1] = '\0';
return Bstrdup(cwd);
return Xstrdup(cwd);
#else
char *e = getenv("HOME");
if (!e) return NULL;
return Bstrdup(e);
return Xstrdup(e);
#endif
}
......@@ -145,7 +136,7 @@ char *Bgetappdir(void)
// trim off the filename
char *slash = Bstrrchr(appdir, '\\');
if (slash) slash[0] = 0;
dir = Bstrdup(appdir);
dir = Xstrdup(appdir);
}
#elif defined EDUKE32_OSX
......@@ -162,7 +153,7 @@ char *Bgetappdir(void)
{
// again, remove executable name with dirname()
// on FreeBSD dirname() seems to use some internal buffer
dir = Bstrdup(dirname(buf));
dir = Xstrdup(dirname(buf));
}
#elif defined __linux || defined EDUKE32_BSD
char buf[PATH_MAX] = {0};
......@@ -177,7 +168,7 @@ char *Bgetappdir(void)
// remove executable name with dirname(3)
// on Linux, dirname() will modify buf2 (cutting off executable name) and return it
// on FreeBSD it seems to use some internal buffer instead.. anyway, just strdup()
dir = Bstrdup(dirname(buf2));
dir = Xstrdup(dirname(buf2));
}
#endif
......@@ -186,7 +177,7 @@ char *Bgetappdir(void)
int32_t Bcorrectfilename(char *filename, int32_t removefn)
{
char *fn = Bstrdup(filename);
char *fn = Xstrdup(filename);
char *tokarr[64], *first, *next = NULL;
for (first=fn; *first; first++)
......@@ -227,7 +218,7 @@ int32_t Bcorrectfilename(char *filename, int32_t removefn)
if (trailslash) *(first++) = '/';
*(first++) = 0;
Bfree(fn);
Xfree(fn);
return 0;
}
......@@ -315,7 +306,7 @@ char *Bgetsystemdrives(void)
number++;
}
str = p = (char *)Bmalloc(1 + (3 * number));
str = p = (char *)Xmalloc(1 + (3 * number));
number = 0;
for (mask = 1; mask < 0x8000000l; mask <<= 1, number++)
{
......@@ -354,10 +345,10 @@ BDIR *Bopendir(const char *name)
BDIR_real *dirr;
#ifdef _MSC_VER
char *t, *tt;
t = (char *)Bmalloc(Bstrlen(name) + 1 + 4);
t = (char *)Xmalloc(Bstrlen(name) + 1 + 4);
#endif
dirr = (BDIR_real *)Bmalloc(sizeof(BDIR_real) + Bstrlen(name));
dirr = (BDIR_real *)Xmalloc(sizeof(BDIR_real) + Bstrlen(name));
#ifdef _MSC_VER
Bstrcpy(t, name);
......@@ -371,17 +362,17 @@ BDIR *Bopendir(const char *name)
*(++tt) = 0;
dirr->dir = _findfirst(t, &dirr->fid);
Bfree(t);
Xfree(t);
if (dirr->dir == -1)
{
Bfree(dirr);
Xfree(dirr);
return NULL;
}
#else
dirr->dir = opendir(name);
if (dirr->dir == NULL)
{
Bfree(dirr);
Xfree(dirr);
return NULL;
}
#endif
......@@ -426,7 +417,7 @@ struct Bdirent *Breaddir(BDIR *dir)
dirr->info.size = 0;
dirr->info.mtime = 0;
char *fn = (char *)Bmalloc(Bstrlen(dirr->name) + 1 + dirr->info.namlen + 1);
char *fn = (char *)Xmalloc(Bstrlen(dirr->name) + 1 + dirr->info.namlen + 1);
Bsprintf(fn, "%s/%s", dirr->name, dirr->info.name);
#ifdef USE_PHYSFS
......@@ -447,7 +438,7 @@ struct Bdirent *Breaddir(BDIR *dir)
}
#endif
Bfree(fn);
Xfree(fn);
return &dirr->info;
}
......@@ -461,7 +452,7 @@ int32_t Bclosedir(BDIR *dir)
#else
closedir(dirr->dir);
#endif
Bfree(dirr);
Xfree(dirr);
return 0;
}
......
......@@ -176,9 +176,9 @@
* Memory routines
**************************************/
#include "compat.h"
#define ALLOC(s) Bmalloc(s)
#define ALLOC_AND_ZERO(s) Bcalloc(1,s)
#define FREEMEM(p) Bfree(p)
#define ALLOC(s) Xmalloc(s)
#define ALLOC_AND_ZERO(s) Xcalloc(1,s)
#define FREEMEM(p) Xfree(p)
#include <string.h> /* memset, memcpy */
#define MEM_INIT(p,v,s) memset((p),(v),(s))
......
......@@ -499,10 +499,10 @@ static GLuint polymost2_compileShader(GLenum shaderType, const char* const sourc
OSD_Printf("Compile Status: %u\n", compileStatus);
if (logLength > 0)
{
char *infoLog = (char*)Bmalloc(logLength);
char *infoLog = (char*)Xmalloc(logLength);
glGetShaderInfoLog(shaderID, logLength, &logLength, infoLog);
OSD_Printf("Log:\n%s\n", infoLog);
Bfree(infoLog);
Xfree(infoLog);
}
}
......@@ -1134,7 +1134,7 @@ void polymost_glinit()
glLinkProgram(polymost1ExtendedShaderProgramID);
int polymost1BasicFragLen = strlen(polymost1Frag);
char* polymost1BasicFrag = (char*) Bmalloc(polymost1BasicFragLen);
char* polymost1BasicFrag = (char*) Xmalloc(polymost1BasicFragLen);
memcpy(polymost1BasicFrag, polymost1Frag, polymost1BasicFragLen);
char* extDefineSubstr = strstr(polymost1BasicFrag, " #define POLYMOST1_EXTENDED");
if (extDefineSubstr)
......@@ -1148,7 +1148,7 @@ void polymost_glinit()
glAttachShader(polymost1BasicShaderProgramID, polymost1BasicVertexShaderID);
glAttachShader(polymost1BasicShaderProgramID, polymost1BasicFragmentShaderID);
glLinkProgram(polymost1BasicShaderProgramID);
Bfree(polymost1BasicFrag);
Xfree(polymost1BasicFrag);
polymost1BasicFrag = 0;
// set defaults
......
......@@ -35,11 +35,11 @@ PoolAllocator::PoolAllocator(size_t const totalSize, size_t const chunkSize) : A
void PoolAllocator::Init()
{
m_start_ptr = Bmalloc(m_totalSize);
m_start_ptr = Xmalloc(m_totalSize);
this->Reset();
}
PoolAllocator::~PoolAllocator() { Bfree(m_start_ptr); }
PoolAllocator::~PoolAllocator() { Xfree(m_start_ptr); }
void *PoolAllocator::Allocate(size_t const allocationSize, size_t const)
{
......
......@@ -19,63 +19,59 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#include <malloc.h>
#include "compat.h"
#include "smmalloc.h"
sm::GenericAllocator::TInstance sm::GenericAllocator::Invalid()
{
return nullptr;
return nullptr;
}
bool sm::GenericAllocator::IsValid(TInstance instance)
{
SMMALLOC_UNUSED(instance);
return true;
SMMALLOC_UNUSED(instance);
return true;
}
sm::GenericAllocator::TInstance sm::GenericAllocator::Create()
{
return nullptr;
return nullptr;
}
void sm::GenericAllocator::Destroy(sm::GenericAllocator::TInstance instance)
{
SMMALLOC_UNUSED(instance);
SMMALLOC_UNUSED(instance);
}
void* sm::GenericAllocator::Alloc(sm::GenericAllocator::TInstance instance, size_t bytesCount, size_t alignment)
{
SMMALLOC_UNUSED(instance);
if (alignment < 16)
{
alignment = 16;
}
return _aligned_malloc(bytesCount, alignment);
SMMALLOC_UNUSED(instance);
if (alignment < 16)
alignment = 16;
return Baligned_alloc(alignment, bytesCount);
}
void sm::GenericAllocator::Free(sm::GenericAllocator::TInstance instance, void* p)
{
SMMALLOC_UNUSED(instance);
_aligned_free(p);
SMMALLOC_UNUSED(instance);
Baligned_free(p);
}
void* sm::GenericAllocator::Realloc(sm::GenericAllocator::TInstance instance, void* p, size_t bytesCount, size_t alignment)
{
SMMALLOC_UNUSED(instance);
return _aligned_realloc(p, bytesCount, alignment);
SMMALLOC_UNUSED(instance);
if (alignment < 16)
alignment = 16;
return Baligned_realloc(p, alignment, bytesCount);
}
size_t sm::GenericAllocator::GetUsableSpace(sm::GenericAllocator::TInstance instance, void* p)
{
SMMALLOC_UNUSED(instance);
size_t alignment = DetectAlignment(p);
#ifdef __GNUC__
if (alignment < sizeof(void*))
alignment = sizeof(void*);
SMMALLOC_UNUSED(instance);
size_t alignment = DetectAlignment(p);
if (alignment < sizeof(void*))
alignment = sizeof(void*);
return _msize(p) - alignment - sizeof(void*);
#else
return _aligned_msize(p, alignment, 0);
#endif
return _msize(p) - alignment - sizeof(void*);
}
......@@ -123,7 +123,7 @@ void artClearMapArt(void)
{
if (faketiledata[i] != g_bakFakeTileData[i])
{
Bfree(faketiledata[i]);
Xfree(faketiledata[i]);
faketiledata[i] = g_bakFakeTileData[i];
}
}
......@@ -225,7 +225,7 @@ static void tileSetDataSafe(int32_t const tile, int32_t tsiz, char const * const
}
else
{
Bfree(newtile);
Xfree(newtile);
}
}
......
......@@ -107,8 +107,8 @@
***************************************/
/*! Modify the local functions below should you wish to use some other memory routines
* for malloc(), free() */
static void* XXH_malloc(size_t s) { return Bmalloc(s); }
static void XXH_free (void* p) { Bfree(p); }
static void* XXH_malloc(size_t s) { return Xmalloc(s); }
static void XXH_free (void* p) { Xfree(p); }
/*! and for memcpy() */
#include <string.h>
static void* XXH_memcpy(void* dest, const void* src, size_t size) { return memcpy(dest,src,size); }
......
......@@ -9892,7 +9892,7 @@ static int32_t loadconsounds(const char *fn)
for (char * m : g_scriptModules)
{
parseconsounds_include(m, NULL, "null");
Bfree(m);
Xfree(m);
}
g_scriptModules.clear();
......
......@@ -418,7 +418,7 @@ void G_CheckCommandLine(int32_t argc, char const * const * argv)
{
if (argc > i+1)
{
Bfree(g_rtsNamePtr);
Xfree(g_rtsNamePtr);
g_rtsNamePtr = dup_filename(argv[i+1]);
initprintf("Using RTS file \"%s\".\n", g_rtsNamePtr);
i++;
......@@ -810,7 +810,7 @@ void G_CheckCommandLine(int32_t argc, char const * const * argv)
}
if (!Bstrcasecmp(k, ".rts"))
{
Bfree(g_rtsNamePtr);
Xfree(g_rtsNamePtr);
g_rtsNamePtr = dup_filename(argv[i++]);
initprintf("Using RTS file \"%s\".\n", g_rtsNamePtr);
continue;
......
......@@ -6667,7 +6667,7 @@ int app_main(int argc, char const* const* argv)
loaddefinitions_game(defsfile, FALSE);
for (char * m : g_defModules)
Bfree(m);
Xfree(m);
g_defModules.clear();
cacheAllSounds();
......@@ -6743,7 +6743,7 @@ int app_main(int argc, char const* const* argv)