Added Xfree() function to accompany the Xmalloc() family of functions and change all uses of Bfree() to Xfree()

This was necessary because everything is already allocated with the Xmalloc() functions, but a future commit will make blocks allocated with those functions no longer compatible with the system implementation of free(), which Bfree() wraps.

git-svn-id: https://svn.eduke32.com/eduke32@7705 1a8010ca-5511-0410-912e-c29ae57300e0

# Conflicts:
#	source/build/src/build.cpp
#	source/build/src/mdsprite.cpp
#	source/build/src/polymer.cpp
#	source/build/src/polymost.cpp
#	source/build/src/texcache.cpp
#	source/build/src/voxmodel.cpp
This commit is contained in:
terminx 2019-06-25 11:29:08 +00:00 committed by Christoph Oelckers
parent dc62b986e8
commit ccdba037b5
47 changed files with 343 additions and 338 deletions

View file

@ -246,7 +246,7 @@ FLAC__StreamDecoderWriteStatus write_flac_stream(const FLAC__StreamDecoder *deco
if (size > fd->blocksize) if (size > fd->blocksize)
{ {
block = (char *)malloc(size); block = (char *)Xmalloc(size);
if (block == nullptr) if (block == nullptr)
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
@ -279,7 +279,7 @@ FLAC__StreamDecoderWriteStatus write_flac_stream(const FLAC__StreamDecoder *deco
char * oldblock = fd->block; char * oldblock = fd->block;
fd->block = block; fd->block = block;
fd->blocksize = size; fd->blocksize = size;
free(oldblock); Xfree(oldblock);
} }
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
@ -436,7 +436,7 @@ int32_t MV_PlayFLAC(char *ptr, uint32_t length, int32_t loopstart, int32_t loope
return MV_Error; return MV_Error;
} }
fd = (flac_data *)calloc(1, sizeof(flac_data)); fd = (flac_data *)Xcalloc(1, sizeof(flac_data));
if (!fd) if (!fd)
{ {
MV_SetErrorCode(MV_InvalidFile); MV_SetErrorCode(MV_InvalidFile);
@ -460,7 +460,7 @@ int32_t MV_PlayFLAC(char *ptr, uint32_t length, int32_t loopstart, int32_t loope
/*metadata_flac_stream*/ NULL, error_flac_stream, /*metadata_flac_stream*/ NULL, error_flac_stream,
(void *)fd) != FLAC__STREAM_DECODER_INIT_STATUS_OK) (void *)fd) != FLAC__STREAM_DECODER_INIT_STATUS_OK)
{ {
free(fd); Xfree(fd);
MV_Printf("MV_PlayFLAC: %s\n", FLAC__stream_decoder_get_resolved_state_string(fd->stream)); MV_Printf("MV_PlayFLAC: %s\n", FLAC__stream_decoder_get_resolved_state_string(fd->stream));
MV_SetErrorCode(MV_InvalidFile); MV_SetErrorCode(MV_InvalidFile);
return MV_Error; return MV_Error;
@ -472,7 +472,7 @@ int32_t MV_PlayFLAC(char *ptr, uint32_t length, int32_t loopstart, int32_t loope
{ {
FLAC__stream_decoder_finish(fd->stream); FLAC__stream_decoder_finish(fd->stream);
FLAC__stream_decoder_delete(fd->stream); FLAC__stream_decoder_delete(fd->stream);
free(fd); Xfree(fd);
MV_SetErrorCode(MV_NoVoices); MV_SetErrorCode(MV_NoVoices);
return MV_Error; return MV_Error;
} }
@ -532,7 +532,7 @@ int32_t MV_PlayFLAC(char *ptr, uint32_t length, int32_t loopstart, int32_t loope
// FLAC__metadata_chain_delete(metadata_chain); // FLAC__metadata_chain_delete(metadata_chain);
FLAC__stream_decoder_finish(fd->stream); FLAC__stream_decoder_finish(fd->stream);
FLAC__stream_decoder_delete(fd->stream); FLAC__stream_decoder_delete(fd->stream);
free(fd); Xfree(fd);
MV_SetErrorCode(MV_InvalidFile); MV_SetErrorCode(MV_InvalidFile);
return MV_Error; return MV_Error;
} }
@ -654,8 +654,8 @@ void MV_ReleaseFLACVoice(VoiceNode *voice)
voice->rawdataptr = 0; voice->rawdataptr = 0;
if (fd->stream != NULL) if (fd->stream != NULL)
{ {
auto stream = fd->stream; auto stream = fd->stream;
fd->stream = nullptr; fd->stream = nullptr;
FLAC__stream_decoder_finish(stream); FLAC__stream_decoder_finish(stream);
FLAC__stream_decoder_delete(stream); FLAC__stream_decoder_delete(stream);
} }
@ -663,8 +663,8 @@ void MV_ReleaseFLACVoice(VoiceNode *voice)
voice->length = 0; voice->length = 0;
voice->sound = nullptr; voice->sound = nullptr;
fd->block = nullptr; fd->block = nullptr;
free(block); Xfree(block);
free(fd); Xfree(fd);
} }
#else #else
#include "_multivc.h" #include "_multivc.h"

View file

@ -94,7 +94,7 @@ extern "C" {
#define LL_Empty(list, next, prev) (((list)->next == (list)) && ((list)->prev == (list))) #define LL_Empty(list, next, prev) (((list)->next == (list)) && ((list)->prev == (list)))
#define LL_Free(list) Bfree(list) #define LL_Free(list) Xfree(list)
#define LL_Reset(list, next, prev) (list)->next = (list)->prev = (list) #define LL_Reset(list, next, prev) (list)->next = (list)->prev = (list)

View file

@ -368,7 +368,7 @@ int32_t MV_PlayVorbis(char *ptr, uint32_t length, int32_t loopstart, int32_t loo
return MV_Error; return MV_Error;
} }
auto vd = (vorbis_data *)calloc(1, sizeof(vorbis_data)); auto vd = (vorbis_data *)Xcalloc(1, sizeof(vorbis_data));
if (!vd) if (!vd)
{ {
@ -386,7 +386,7 @@ int32_t MV_PlayVorbis(char *ptr, uint32_t length, int32_t loopstart, int32_t loo
if (status < 0) if (status < 0)
{ {
free(vd); Xfree(vd);
MV_Printf("MV_PlayVorbis: err %d\n", status); MV_Printf("MV_PlayVorbis: err %d\n", status);
MV_SetErrorCode(MV_InvalidFile); MV_SetErrorCode(MV_InvalidFile);
return MV_Error; return MV_Error;
@ -397,7 +397,7 @@ int32_t MV_PlayVorbis(char *ptr, uint32_t length, int32_t loopstart, int32_t loo
if (!vi) if (!vi)
{ {
ov_clear(&vd->vf); ov_clear(&vd->vf);
free(vd); Xfree(vd);
MV_SetErrorCode(MV_InvalidFile); MV_SetErrorCode(MV_InvalidFile);
return MV_Error; return MV_Error;
} }
@ -405,7 +405,7 @@ int32_t MV_PlayVorbis(char *ptr, uint32_t length, int32_t loopstart, int32_t loo
if (vi->channels != 1 && vi->channels != 2) if (vi->channels != 1 && vi->channels != 2)
{ {
ov_clear(&vd->vf); ov_clear(&vd->vf);
free(vd); Xfree(vd);
MV_SetErrorCode(MV_InvalidFile); MV_SetErrorCode(MV_InvalidFile);
return MV_Error; return MV_Error;
} }
@ -416,7 +416,7 @@ int32_t MV_PlayVorbis(char *ptr, uint32_t length, int32_t loopstart, int32_t loo
if (voice == NULL) if (voice == NULL)
{ {
ov_clear(&vd->vf); ov_clear(&vd->vf);
free(vd); Xfree(vd);
MV_SetErrorCode(MV_NoVoices); MV_SetErrorCode(MV_NoVoices);
return MV_Error; return MV_Error;
} }
@ -464,7 +464,7 @@ void MV_ReleaseVorbisVoice( VoiceNode * voice )
voice->length = 0; voice->length = 0;
voice->sound = nullptr; voice->sound = nullptr;
ov_clear(&vd->vf); ov_clear(&vd->vf);
free(vd); Xfree(vd);
} }
#else #else
#include "_multivc.h" #include "_multivc.h"

View file

@ -441,7 +441,7 @@ int32_t MV_PlayXA(char *ptr, uint32_t length, int32_t loopstart, int32_t loopend
if ( voice == NULL ) if ( voice == NULL )
{ {
free(xad); Xfree(xad);
MV_SetErrorCode( MV_NoVoices ); MV_SetErrorCode( MV_NoVoices );
return MV_Error; return MV_Error;
} }
@ -486,5 +486,5 @@ void MV_ReleaseXAVoice( VoiceNode * voice )
voice->rawdataptr = 0; voice->rawdataptr = 0;
voice->length = 0; voice->length = 0;
voice->sound = nullptr; voice->sound = nullptr;
free(xad); Xfree(xad);
} }

View file

@ -124,14 +124,14 @@ int32_t MV_PlayXMP(char *ptr, uint32_t length, int32_t loopstart, int32_t loopen
if ((xmpd->context = xmp_create_context()) == NULL) if ((xmpd->context = xmp_create_context()) == NULL)
{ {
free(xmpd); Xfree(xmpd);
MV_SetErrorCode(MV_InvalidFile); MV_SetErrorCode(MV_InvalidFile);
return MV_Error; return MV_Error;
} }
if ((retval = xmp_load_module_from_memory(xmpd->context, ptr, length)) != 0) if ((retval = xmp_load_module_from_memory(xmpd->context, ptr, length)) != 0)
{ {
free(xmpd); Xfree(xmpd);
MV_Printf("MV_PlayXMP: xmp_load_module_from_memory failed (%i)\n", retval); MV_Printf("MV_PlayXMP: xmp_load_module_from_memory failed (%i)\n", retval);
MV_SetErrorCode(MV_InvalidFile); MV_SetErrorCode(MV_InvalidFile);
return MV_Error; return MV_Error;
@ -143,7 +143,7 @@ int32_t MV_PlayXMP(char *ptr, uint32_t length, int32_t loopstart, int32_t loopen
{ {
xmp_release_module(xmpd->context); xmp_release_module(xmpd->context);
xmp_free_context(xmpd->context); xmp_free_context(xmpd->context);
free(xmpd); Xfree(xmpd);
MV_SetErrorCode(MV_NoVoices); MV_SetErrorCode(MV_NoVoices);
return MV_Error; return MV_Error;
} }
@ -202,7 +202,7 @@ void MV_ReleaseXMPVoice(VoiceNode * voice)
xmp_end_player(xmpd->context); xmp_end_player(xmpd->context);
xmp_release_module(xmpd->context); xmp_release_module(xmpd->context);
xmp_free_context(xmpd->context); xmp_free_context(xmpd->context);
free(xmpd); Xfree(xmpd);
} }
#else #else

View file

@ -915,18 +915,18 @@ static FORCE_INLINE void *Baligned_alloc(const size_t alignment, const size_t si
#if defined _WIN32 && !defined NO_ALIGNED_MALLOC #if defined _WIN32 && !defined NO_ALIGNED_MALLOC
# define Baligned_free _aligned_free # define Baligned_free _aligned_free
#else #else
# define Baligned_free Bfree # define Baligned_free Xfree
#endif #endif
////////// Pointer management ////////// ////////// Pointer management //////////
#define DO_FREE_AND_NULL(var) do { \ #define DO_FREE_AND_NULL(var) do { \
Bfree(var); (var) = NULL; \ Xfree(var); (var) = NULL; \
} while (0) } while (0)
#define ALIGNED_FREE_AND_NULL(var) do { \ #define ALIGNED_FREE_AND_NULL(var) do { \
Baligned_free(var); (var) = NULL; \ Xaligned_free(var); (var) = NULL; \
} while (0) } while (0)
@ -1302,6 +1302,10 @@ static FORCE_INLINE void *xrealloc(void * const ptr, const bsize_t size)
return (EDUKE32_PREDICT_TRUE(newptr != NULL || size == 0)) ? newptr: handle_memerr(ptr); return (EDUKE32_PREDICT_TRUE(newptr != NULL || size == 0)) ? newptr: handle_memerr(ptr);
} }
static FORCE_INLINE void xfree(void *const ptr) { Bfree(ptr); }
static FORCE_INLINE void xaligned_free(void *const ptr) { Baligned_free(ptr); }
#if !defined NO_ALIGNED_MALLOC #if !defined NO_ALIGNED_MALLOC
static FORCE_INLINE void *xaligned_alloc(const bsize_t alignment, const bsize_t size) static FORCE_INLINE void *xaligned_alloc(const bsize_t alignment, const bsize_t size)
{ {
@ -1323,7 +1327,8 @@ static FORCE_INLINE void *xaligned_alloc(const bsize_t alignment, const bsize_t
#define Xcalloc(nmemb, size) (EDUKE32_PRE_XALLOC xcalloc(nmemb, size)) #define Xcalloc(nmemb, size) (EDUKE32_PRE_XALLOC xcalloc(nmemb, size))
#define Xrealloc(ptr, size) (EDUKE32_PRE_XALLOC xrealloc(ptr, size)) #define Xrealloc(ptr, size) (EDUKE32_PRE_XALLOC xrealloc(ptr, size))
#define Xaligned_alloc(alignment, size) (EDUKE32_PRE_XALLOC xaligned_alloc(alignment, size)) #define Xaligned_alloc(alignment, size) (EDUKE32_PRE_XALLOC xaligned_alloc(alignment, size))
#define Xfree(ptr) (EDUKE32_PRE_XALLOC xfree(ptr))
#define Xaligned_free(ptr) (EDUKE32_PRE_XALLOC xaligned_free(ptr))
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -220,7 +220,7 @@ void calc_ylookup(int32_t bpl, int32_t lastyidx)
if (lastyidx > ylookupsiz) if (lastyidx > ylookupsiz)
{ {
Baligned_free(ylookup); Xaligned_free(ylookup);
ylookup = (intptr_t *)Xaligned_alloc(16, lastyidx * sizeof(intptr_t)); ylookup = (intptr_t *)Xaligned_alloc(16, lastyidx * sizeof(intptr_t));
ylookupsiz = lastyidx; ylookupsiz = lastyidx;

View file

@ -382,13 +382,13 @@ int32_t addsearchpath_user(const char *p, int32_t user)
if (Bstat(path, &st) < 0) if (Bstat(path, &st) < 0)
{ {
Bfree(path); Xfree(path);
if (errno == ENOENT) return -2; if (errno == ENOENT) return -2;
return -1; return -1;
} }
if (!(st.st_mode & BS_IFDIR)) if (!(st.st_mode & BS_IFDIR))
{ {
Bfree(path); Xfree(path);
return -1; return -1;
} }
@ -415,7 +415,7 @@ int32_t addsearchpath_user(const char *p, int32_t user)
initprintf("Using %s for game data\n", srch->path); initprintf("Using %s for game data\n", srch->path);
Bfree(path); Xfree(path);
return 0; return 0;
} }
@ -461,13 +461,13 @@ int32_t removesearchpath(const char *p)
} }
} }
Bfree(srch->path); Xfree(srch->path);
Bfree(srch); Xfree(srch);
break; break;
} }
} }
Bfree(path); Xfree(path);
return 0; return 0;
} }
@ -498,8 +498,8 @@ void removesearchpaths_withuser(int32_t usermask)
} }
} }
Bfree(srch->path); Xfree(srch->path);
Bfree(srch); Xfree(srch);
} }
} }
} }
@ -536,7 +536,7 @@ int32_t findfrompath(const char *fn, char **where)
return 0; return 0;
} }
Bfree(tfn); Xfree(tfn);
} }
#endif #endif
} }
@ -559,7 +559,7 @@ int32_t findfrompath(const char *fn, char **where)
if (buildvfs_exists(pfn)) if (buildvfs_exists(pfn))
{ {
*where = pfn; *where = pfn;
Bfree(ffn); Xfree(ffn);
return 0; return 0;
} }
@ -573,8 +573,8 @@ int32_t findfrompath(const char *fn, char **where)
if (buildvfs_exists(pfn)) if (buildvfs_exists(pfn))
{ {
*where = pfn; *where = pfn;
Bfree(ffn); Xfree(ffn);
Bfree(tfn); Xfree(tfn);
return 0; return 0;
} }
@ -586,8 +586,8 @@ int32_t findfrompath(const char *fn, char **where)
if (buildvfs_exists(pfn)) if (buildvfs_exists(pfn))
{ {
*where = pfn; *where = pfn;
Bfree(ffn); Xfree(ffn);
Bfree(tfn); Xfree(tfn);
return 0; return 0;
} }
@ -598,15 +598,15 @@ int32_t findfrompath(const char *fn, char **where)
if (buildvfs_exists(pfn)) if (buildvfs_exists(pfn))
{ {
*where = pfn; *where = pfn;
Bfree(ffn); Xfree(ffn);
Bfree(tfn); Xfree(tfn);
return 0; return 0;
} }
#endif #endif
Bfree(tfn); Xfree(tfn);
} }
Bfree(pfn); Bfree(ffn); Xfree(pfn); Xfree(ffn);
return -1; return -1;
} }
@ -628,7 +628,7 @@ buildvfs_kfd openfrompath(const char *fn, int32_t flags, int32_t mode)
buildvfs_kfd h = openfrompath_internal(fn, &pfn, flags, mode); buildvfs_kfd h = openfrompath_internal(fn, &pfn, flags, mode);
Bfree(pfn); Xfree(pfn);
return h; return h;
} }
@ -737,15 +737,15 @@ int initgroupfile(const char *filename)
kclose_grp(numgroupfiles); kclose_grp(numgroupfiles);
kzaddstack(zfn); kzaddstack(zfn);
Bfree(zfn); Xfree(zfn);
return MAXGROUPFILES; return MAXGROUPFILES;
} }
klseek_grp(numgroupfiles,0,BSEEK_SET); klseek_grp(numgroupfiles,0,BSEEK_SET);
Bfree(zfn); Xfree(zfn);
} }
#else #else
Bfree(zfn); Xfree(zfn);
#endif #endif
// check if GRP // check if GRP
@ -932,7 +932,7 @@ static int32_t check_filename_mismatch(const char * const filename, int ofs)
if (!Bstrncmp(fnbuf+ofs, tfn, len)) if (!Bstrncmp(fnbuf+ofs, tfn, len))
{ {
Bfree(tfn); Xfree(tfn);
return 0; return 0;
} }
@ -940,11 +940,11 @@ static int32_t check_filename_mismatch(const char * const filename, int ofs)
if (!Bstrncmp(fnbuf+ofs, tfn, len)) if (!Bstrncmp(fnbuf+ofs, tfn, len))
{ {
Bfree(tfn); Xfree(tfn);
return 0; return 0;
} }
Bfree(tfn); Xfree(tfn);
return 1; return 1;
} }
@ -1087,7 +1087,7 @@ int32_t kopen4load(const char *filename, char searchfirst)
int32_t h = kopen_internal(filename, &lastpfn, searchfirst, 1, 1, newhandle, filegrp, filehan, filepos); int32_t h = kopen_internal(filename, &lastpfn, searchfirst, 1, 1, newhandle, filegrp, filehan, filepos);
Bfree(lastpfn); Xfree(lastpfn);
return h; return h;
} }
@ -1378,7 +1378,7 @@ void klistfree(CACHE1D_FIND_REC *rec)
while (rec) while (rec)
{ {
n = rec->next; n = rec->next;
Bfree(rec); Xfree(rec);
rec = n; rec = n;
} }
} }
@ -1407,7 +1407,7 @@ CACHE1D_FIND_REC *klistpath(const char *_path, const char *mask, int32_t type)
{ {
if (klistaddentry(&rec, "..", CACHE1D_FIND_DIR, CACHE1D_SOURCE_CURDIR) < 0) if (klistaddentry(&rec, "..", CACHE1D_FIND_DIR, CACHE1D_SOURCE_CURDIR) < 0)
{ {
Bfree(path); Xfree(path);
klistfree(rec); klistfree(rec);
return NULL; return NULL;
} }
@ -1627,20 +1627,20 @@ next:
{ {
if (klistaddentry(&rec, drp, CACHE1D_FIND_DRIVE, CACHE1D_SOURCE_DRIVE) < 0) if (klistaddentry(&rec, drp, CACHE1D_FIND_DRIVE, CACHE1D_SOURCE_DRIVE) < 0)
{ {
Bfree(drives); Xfree(drives);
goto failure; goto failure;
} }
} }
Bfree(drives); Xfree(drives);
} }
} }
Bfree(path); Xfree(path);
// XXX: may be NULL if no file was listed, and thus indistinguishable from // XXX: may be NULL if no file was listed, and thus indistinguishable from
// an error condition. // an error condition.
return rec; return rec;
failure: failure:
Bfree(path); Xfree(path);
klistfree(rec); klistfree(rec);
return NULL; return NULL;
} }
@ -1690,7 +1690,7 @@ int32_t kdfread_LZ4(void *buffer, int dasizeof, int count, buildvfs_kfd fil)
int32_t decompressedLength = LZ4_decompress_safe(pCompressedData, (char*) buffer, leng, dasizeof*count); int32_t decompressedLength = LZ4_decompress_safe(pCompressedData, (char*) buffer, leng, dasizeof*count);
if (pCompressedData != compressedDataStackBuf) if (pCompressedData != compressedDataStackBuf)
Baligned_free(pCompressedData); Xaligned_free(pCompressedData);
return decompressedLength/dasizeof; return decompressedLength/dasizeof;
} }
@ -1716,5 +1716,5 @@ void dfwrite_LZ4(const void *buffer, int dasizeof, int count, buildvfs_FILE fil)
buildvfs_fwrite(pCompressedData, leng, 1, fil); buildvfs_fwrite(pCompressedData, leng, 1, fil);
if (pCompressedData != compressedDataStackBuf) if (pCompressedData != compressedDataStackBuf)
Baligned_free(pCompressedData); Xaligned_free(pCompressedData);
} }

View file

@ -168,8 +168,8 @@ int32_t engineLoadClipMaps(void)
{ {
engineInitClipMaps(); engineInitClipMaps();
Bfree(fisec); Xfree(fisec);
Bfree(fispr); Xfree(fispr);
return -1; return -1;
} }
@ -254,8 +254,8 @@ int32_t engineLoadClipMaps(void)
clipinfo[sectoidx[k]].picnum); clipinfo[sectoidx[k]].picnum);
engineInitClipMaps(); engineInitClipMaps();
Bfree(fisec); Xfree(fisec);
Bfree(fispr); Xfree(fispr);
return 2; return 2;
} }
@ -318,8 +318,8 @@ int32_t engineLoadClipMaps(void)
" for sprite %d.\n", g_clipMapFiles[fi], outersect-fisec[fi], ns-fisec[fi], i-fispr[fi]); " for sprite %d.\n", g_clipMapFiles[fi], outersect-fisec[fi], ns-fisec[fi], i-fispr[fi]);
engineInitClipMaps(); engineInitClipMaps();
Bfree(fisec); Xfree(fisec);
Bfree(fispr); Xfree(fispr);
return 3; return 3;
} }
@ -337,8 +337,8 @@ int32_t engineLoadClipMaps(void)
g_clipMapFiles[fi], ns-fisec[fi], sectoidx[ns], i-fispr[fi], numclipmaps); g_clipMapFiles[fi], ns-fisec[fi], sectoidx[ns], i-fispr[fi], numclipmaps);
engineInitClipMaps(); engineInitClipMaps();
Bfree(fisec); Xfree(fisec);
Bfree(fispr); Xfree(fispr);
return 4; return 4;
} }
@ -351,8 +351,8 @@ int32_t engineLoadClipMaps(void)
initprintf("clip map: INTERNAL ERROR: outersect==-1!\n"); initprintf("clip map: INTERNAL ERROR: outersect==-1!\n");
engineInitClipMaps(); engineInitClipMaps();
Bfree(fisec); Xfree(fisec);
Bfree(fispr); Xfree(fispr);
return 5; return 5;
} }
@ -517,8 +517,8 @@ int32_t engineLoadClipMaps(void)
if (lwcp > 0) if (lwcp > 0)
initprintf("Loaded clip map%s.\n", lwcp==1 ? "" : "s"); initprintf("Loaded clip map%s.\n", lwcp==1 ? "" : "s");
Bfree(fisec); Xfree(fisec);
Bfree(fispr); Xfree(fispr);
return 0; return 0;
} }

View file

@ -66,7 +66,7 @@ char *g_defNamePtr = NULL;
void clearDefNamePtr(void) void clearDefNamePtr(void)
{ {
Bfree(g_defNamePtr); Xfree(g_defNamePtr);
// g_defNamePtr assumed to be assigned to right after // g_defNamePtr assumed to be assigned to right after
} }
@ -160,7 +160,7 @@ int32_t check_file_exist(const char *fn)
return 1; return 1;
} }
} }
else Bfree(tfn); else Xfree(tfn);
pathsearchmode = opsm; pathsearchmode = opsm;
return 0; return 0;

View file

@ -221,7 +221,7 @@ int32_t Bcorrectfilename(char *filename, int32_t removefn)
if (trailslash) *(first++) = '/'; if (trailslash) *(first++) = '/';
*(first++) = 0; *(first++) = 0;
Bfree(fn); Xfree(fn);
return 0; return 0;
} }
@ -365,17 +365,17 @@ BDIR *Bopendir(const char *name)
*(++tt) = 0; *(++tt) = 0;
dirr->dir = _findfirst(t, &dirr->fid); dirr->dir = _findfirst(t, &dirr->fid);
Bfree(t); Xfree(t);
if (dirr->dir == -1) if (dirr->dir == -1)
{ {
Bfree(dirr); Xfree(dirr);
return NULL; return NULL;
} }
#else #else
dirr->dir = opendir(name); dirr->dir = opendir(name);
if (dirr->dir == NULL) if (dirr->dir == NULL)
{ {
Bfree(dirr); Xfree(dirr);
return NULL; return NULL;
} }
#endif #endif
@ -441,7 +441,7 @@ struct Bdirent *Breaddir(BDIR *dir)
} }
#endif #endif
Bfree(fn); Xfree(fn);
return &dirr->info; return &dirr->info;
} }
@ -455,7 +455,7 @@ int32_t Bclosedir(BDIR *dir)
#else #else
closedir(dirr->dir); closedir(dirr->dir);
#endif #endif
Bfree(dirr); Xfree(dirr);
return 0; return 0;
} }

View file

@ -327,7 +327,7 @@ void writesettings(void) // save binds and aliases to <cfgname>_m32_settings.cfg
OSD_Printf("Wrote m32_settings.cfg\n"); OSD_Printf("Wrote m32_settings.cfg\n");
else OSD_Printf("Wrote %s_m32_settings.cfg\n",ptr); else OSD_Printf("Wrote %s_m32_settings.cfg\n",ptr);
Bfree(ptr); Xfree(ptr);
return; return;
} }
@ -335,7 +335,7 @@ void writesettings(void) // save binds and aliases to <cfgname>_m32_settings.cfg
OSD_Printf("Error writing m32_settings.cfg: %s\n", strerror(errno)); OSD_Printf("Error writing m32_settings.cfg: %s\n", strerror(errno));
else OSD_Printf("Error writing %s_m32_settings.cfg: %s\n",ptr,strerror(errno)); else OSD_Printf("Error writing %s_m32_settings.cfg: %s\n",ptr,strerror(errno));
Bfree(ptr); Xfree(ptr);
} }
int32_t writesetup(const char *fn) int32_t writesetup(const char *fn)

View file

@ -305,7 +305,7 @@ static int32_t Defs_ImportTileFromTexture(char const * const fn, int32_t const t
tile_from_truecolpic(tile, picptr, alphacut); tile_from_truecolpic(tile, picptr, alphacut);
Bfree(picptr); Xfree(picptr);
#ifdef USE_OPENGL #ifdef USE_OPENGL
if (istexture) if (istexture)
@ -2054,7 +2054,7 @@ static int32_t defsparser(scriptfile *script)
klseek(fd, 0, SEEK_SET); klseek(fd, 0, SEEK_SET);
if (kread(fd, filebuf, filesize)!=filesize) if (kread(fd, filebuf, filesize)!=filesize)
{ kclose(fd); Bfree(highpaldata); initprintf("Error: didn't read all of \"%s\".\n", fn); break; } { kclose(fd); Xfree(highpaldata); initprintf("Error: didn't read all of \"%s\".\n", fn); break; }
kclose(fd); kclose(fd);
kpgetdim(filebuf, filesize, &xsiz, &ysiz); kpgetdim(filebuf, filesize, &xsiz, &ysiz);
@ -2063,19 +2063,19 @@ static int32_t defsparser(scriptfile *script)
{ {
initprintf("Error: image dimensions of \"%s\" must be %dx%d.\n", initprintf("Error: image dimensions of \"%s\" must be %dx%d.\n",
fn, PR_HIGHPALOOKUP_DIM*PR_HIGHPALOOKUP_DIM, PR_HIGHPALOOKUP_DIM); fn, PR_HIGHPALOOKUP_DIM*PR_HIGHPALOOKUP_DIM, PR_HIGHPALOOKUP_DIM);
Bfree(filebuf); Bfree(highpaldata); Xfree(filebuf); Xfree(highpaldata);
break; break;
} }
i = kprender(filebuf, filesize, (intptr_t)highpaldata, xsiz*sizeof(coltype), xsiz, ysiz); i = kprender(filebuf, filesize, (intptr_t)highpaldata, xsiz*sizeof(coltype), xsiz, ysiz);
Bfree(filebuf); Xfree(filebuf);
if (EDUKE32_PREDICT_FALSE(i)) if (EDUKE32_PREDICT_FALSE(i))
{ Bfree(highpaldata); initprintf("Error: failed rendering \"%s\".\n", fn); break; } { Xfree(highpaldata); initprintf("Error: failed rendering \"%s\".\n", fn); break; }
} }
polymer_definehighpalookup(basepal, pal, highpaldata); polymer_definehighpalookup(basepal, pal, highpaldata);
Bfree(highpaldata); Xfree(highpaldata);
#endif #endif
} }
break; break;
@ -2884,7 +2884,7 @@ static int32_t defsparser(scriptfile *script)
{ {
initprintf("Error: basepalette: Read failed on line %s:%d\n", initprintf("Error: basepalette: Read failed on line %s:%d\n",
script->filename, scriptfile_getlinum(script,cmdtokptr)); script->filename, scriptfile_getlinum(script,cmdtokptr));
Bfree(palbuf); Xfree(palbuf);
kclose(fil); kclose(fil);
break; break;
} }
@ -2898,7 +2898,7 @@ static int32_t defsparser(scriptfile *script)
paletteSetColorTable(id, palbuf); paletteSetColorTable(id, palbuf);
didLoadPal = 1; didLoadPal = 1;
Bfree(palbuf); Xfree(palbuf);
kclose(fil); kclose(fil);
break; break;
} }
@ -3065,7 +3065,7 @@ static int32_t defsparser(scriptfile *script)
{ {
initprintf("Error: palookup: Read failed on line %s:%d\n", initprintf("Error: palookup: Read failed on line %s:%d\n",
script->filename, scriptfile_getlinum(script,cmdtokptr)); script->filename, scriptfile_getlinum(script,cmdtokptr));
Bfree(palookupbuf); Xfree(palookupbuf);
kclose(fil); kclose(fil);
break; break;
} }
@ -3088,7 +3088,7 @@ static int32_t defsparser(scriptfile *script)
paletteMakeLookupTable(id, palookupbuf, 0,0,0, g_noFloorPal[id]); paletteMakeLookupTable(id, palookupbuf, 0,0,0, g_noFloorPal[id]);
} }
Bfree(palookupbuf); Xfree(palookupbuf);
kclose(fil); kclose(fil);
break; break;
} }
@ -3364,7 +3364,7 @@ static int32_t defsparser(scriptfile *script)
{ {
initprintf("Error: blendtable: Read failed on line %s:%d\n", initprintf("Error: blendtable: Read failed on line %s:%d\n",
script->filename, scriptfile_getlinum(script,cmdtokptr)); script->filename, scriptfile_getlinum(script,cmdtokptr));
Bfree(blendbuf); Xfree(blendbuf);
kclose(fil); kclose(fil);
break; break;
} }
@ -3372,7 +3372,7 @@ static int32_t defsparser(scriptfile *script)
paletteSetBlendTable(id, blendbuf); paletteSetBlendTable(id, blendbuf);
didLoadTransluc = 1; didLoadTransluc = 1;
Bfree(blendbuf); Xfree(blendbuf);
kclose(fil); kclose(fil);
break; break;
} }

View file

@ -4405,7 +4405,7 @@ static void classicDrawBunches(int32_t bunch)
Bmemcpy((char *)frameplace, bakframe, xdim*ydim); Bmemcpy((char *)frameplace, bakframe, xdim*ydim);
videoEndDrawing(); //}}} videoEndDrawing(); //}}}
Baligned_free(bakframe); Xaligned_free(bakframe);
} }
#endif #endif
} }
@ -7757,7 +7757,7 @@ int32_t enginePreInit(void)
#else #else
for (i = 0; i < (signed) ARRAY_SIZE(dynarray); i++) for (i = 0; i < (signed) ARRAY_SIZE(dynarray); i++)
{ {
Baligned_free(*dynarray[i].ptr); Xaligned_free(*dynarray[i].ptr);
*dynarray[i].ptr = Xaligned_alloc(16, dynarray[i].size); *dynarray[i].ptr = Xaligned_alloc(16, dynarray[i].size);
} }
#endif #endif
@ -7916,16 +7916,16 @@ void engineUnInit(void)
if (i==0 || palookup[i] != palookup[0]) if (i==0 || palookup[i] != palookup[0])
{ {
// Take care of handling aliased ^^^ cases! // Take care of handling aliased ^^^ cases!
Baligned_free(palookup[i]); Xaligned_free(palookup[i]);
} }
Bmemset(palookup, 0, sizeof(palookup)); Bmemset(palookup, 0, sizeof(palookup));
for (bssize_t i=0; i<MAXBLENDTABS; i++) for (bssize_t i=0; i<MAXBLENDTABS; i++)
Bfree(blendtable[i]); Xfree(blendtable[i]);
Bmemset(blendtable, 0, sizeof(blendtable)); Bmemset(blendtable, 0, sizeof(blendtable));
for (bssize_t i=1; i<MAXBASEPALS; i++) for (bssize_t i=1; i<MAXBASEPALS; i++)
Bfree(basepaltable[i]); Xfree(basepaltable[i]);
Bmemset(basepaltable, 0, sizeof(basepaltable)); Bmemset(basepaltable, 0, sizeof(basepaltable));
basepaltable[0] = palette; basepaltable[0] = palette;
@ -7939,8 +7939,8 @@ void engineUnInit(void)
for (bssize_t i = 0; i < num_usermaphacks; i++) for (bssize_t i = 0; i < num_usermaphacks; i++)
{ {
Bfree(usermaphacks[i].mhkfile); Xfree(usermaphacks[i].mhkfile);
Bfree(usermaphacks[i].title); Xfree(usermaphacks[i].title);
} }
DO_FREE_AND_NULL(usermaphacks); DO_FREE_AND_NULL(usermaphacks);
num_usermaphacks = 0; num_usermaphacks = 0;
@ -9467,7 +9467,7 @@ skip_reading_mapbin:
uint8_t *fullboard = (uint8_t*)Xmalloc(boardsize); uint8_t *fullboard = (uint8_t*)Xmalloc(boardsize);
kread(fil, fullboard, boardsize); kread(fil, fullboard, boardsize);
md4once(fullboard, boardsize, g_loadedMapHack.md4); md4once(fullboard, boardsize, g_loadedMapHack.md4);
Bfree(fullboard); Xfree(fullboard);
kclose(fil); kclose(fil);
// Done reading file. // Done reading file.
@ -9854,7 +9854,7 @@ int32_t saveboard(const char *filename, const vec3_t *dapos, int16_t daang, int1
} }
buildvfs_write(fil, tsect, sizeof(sectortypev7)*numsectors); buildvfs_write(fil, tsect, sizeof(sectortypev7)*numsectors);
Bfree(tsect); Xfree(tsect);
ts = B_LITTLE16(numwalls); ts = B_LITTLE16(numwalls);
buildvfs_write(fil,&ts,2); buildvfs_write(fil,&ts,2);
@ -9897,7 +9897,7 @@ int32_t saveboard(const char *filename, const vec3_t *dapos, int16_t daang, int1
} }
buildvfs_write(fil, twall, sizeof(walltypev7)*numwalls); buildvfs_write(fil, twall, sizeof(walltypev7)*numwalls);
Bfree(twall); Xfree(twall);
ts = B_LITTLE16(numsprites); buildvfs_write(fil,&ts,2); ts = B_LITTLE16(numsprites); buildvfs_write(fil,&ts,2);
@ -9931,7 +9931,7 @@ int32_t saveboard(const char *filename, const vec3_t *dapos, int16_t daang, int1
} }
buildvfs_write(fil, tspri, sizeof(spritetype)*numsprites); buildvfs_write(fil, tspri, sizeof(spritetype)*numsprites);
Bfree(tspri); Xfree(tspri);
} }
buildvfs_close(fil); buildvfs_close(fil);
@ -9978,7 +9978,7 @@ static void videoAllocateBuffers(void)
for (i = 0; i < (signed)ARRAY_SIZE(dynarray); i++) for (i = 0; i < (signed)ARRAY_SIZE(dynarray); i++)
{ {
Baligned_free(*dynarray[i].ptr); Xaligned_free(*dynarray[i].ptr);
*dynarray[i].ptr = Xaligned_alloc(16, dynarray[i].size); *dynarray[i].ptr = Xaligned_alloc(16, dynarray[i].size);
} }
@ -10097,7 +10097,7 @@ int32_t videoSetGameMode(char davidoption, int32_t daupscaledxdim, int32_t daups
swallf = (float *) Xrealloc(swallf, xdim * sizeof(float)); swallf = (float *) Xrealloc(swallf, xdim * sizeof(float));
#endif #endif
Bfree(lookups); Xfree(lookups);
j = ydim*4; //Leave room for horizlookup&horizlookup2 j = ydim*4; //Leave room for horizlookup&horizlookup2
lookups = (int32_t *)Xmalloc(2*j*sizeof(lookups[0])); lookups = (int32_t *)Xmalloc(2*j*sizeof(lookups[0]));
@ -10245,7 +10245,7 @@ int32_t qloadkvx(int32_t voxindex, const char *filename)
voxmodels[voxindex] = NULL; voxmodels[voxindex] = NULL;
} }
Bfree(voxfilenames[voxindex]); Xfree(voxfilenames[voxindex]);
voxfilenames[voxindex] = Xstrdup(filename); voxfilenames[voxindex] = Xstrdup(filename);
g_haveVoxels = 1; g_haveVoxels = 1;
#endif #endif
@ -12117,7 +12117,7 @@ void setfirstwall(int16_t sectnum, int16_t newfirstwall)
} }
#endif #endif
Bfree(tmpwall); Xfree(tmpwall);
} }
// //

View file

@ -47,7 +47,7 @@ static GLuint compileShader(GLenum shaderType, const char* const source)
char *infoLog = (char*) Xmalloc(logLength); char *infoLog = (char*) Xmalloc(logLength);
glGetShaderInfoLog(shaderID, logLength, &logLength, infoLog); glGetShaderInfoLog(shaderID, logLength, &logLength, infoLog);
OSD_Printf("Log:\n%s\n", infoLog); OSD_Printf("Log:\n%s\n", infoLog);
Bfree(infoLog); Xfree(infoLog);
} }
} }

View file

@ -35,8 +35,8 @@ void hash_free(hashtable_t *t)
hashitem_t * const tmp = cur; hashitem_t * const tmp = cur;
cur = cur->next; cur = cur->next;
Bfree(tmp->string); Xfree(tmp->string);
Bfree(tmp); Xfree(tmp);
} }
} while (--remaining >= 0); } while (--remaining >= 0);
@ -112,14 +112,14 @@ void hash_delete(hashtable_t *t, const char *s)
{ {
if (Bstrcmp(s, cur->string) == 0) if (Bstrcmp(s, cur->string) == 0)
{ {
Bfree(cur->string); Xfree(cur->string);
if (!prev) if (!prev)
t->items[code] = cur->next; t->items[code] = cur->next;
else else
prev->next = cur->next; prev->next = cur->next;
Bfree(cur); Xfree(cur);
break; break;
} }

View file

@ -96,12 +96,12 @@ void hicinit(void)
if (hr->skybox) if (hr->skybox)
{ {
for (j=5; j>=0; j--) for (j=5; j>=0; j--)
Bfree(hr->skybox->face[j]); Xfree(hr->skybox->face[j]);
Bfree(hr->skybox); Xfree(hr->skybox);
} }
Bfree(hr->filename); Xfree(hr->filename);
Bfree(hr); Xfree(hr);
hr = next; hr = next;
} }
@ -163,7 +163,7 @@ int32_t hicsetsubsttex(int32_t picnum, int32_t palnum, const char *filen, float
else hrn = hr; else hrn = hr;
// store into hicreplc the details for this replacement // store into hicreplc the details for this replacement
Bfree(hrn->filename); Xfree(hrn->filename);
hrn->filename = Xstrdup(filen); hrn->filename = Xstrdup(filen);
hrn->alphacut = min(alphacut,1.f); hrn->alphacut = min(alphacut,1.f);
@ -268,18 +268,18 @@ int32_t hicclearsubst(int32_t picnum, int32_t palnum)
if (!hr) return 0; if (!hr) return 0;
Bfree(hr->filename); Xfree(hr->filename);
if (hr->skybox) if (hr->skybox)
{ {
int32_t i; int32_t i;
for (i=5; i>=0; i--) for (i=5; i>=0; i--)
Bfree(hr->skybox->face[i]); Xfree(hr->skybox->face[i]);
Bfree(hr->skybox); Xfree(hr->skybox);
} }
if (hrn) hrn->next = hr->next; if (hrn) hrn->next = hr->next;
else hicreplc[picnum] = hr->next; else hicreplc[picnum] = hr->next;
Bfree(hr); Xfree(hr);
return 0; return 0;
} }

View file

@ -1369,9 +1369,9 @@ static int32_t kpegrend(const char *kfilebuf, int32_t kfilength,
kfileptr += leng; kfileptr += leng;
break; break;
case 0xda: case 0xda:
if ((xdim <= 0) || (ydim <= 0)) { Bfree(dctbuf); return -1; } if ((xdim <= 0) || (ydim <= 0)) { Xfree(dctbuf); return -1; }
lnumcomponents = (int32_t)(*kfileptr++); if (!lnumcomponents) { Bfree(dctbuf); return -1; } lnumcomponents = (int32_t)(*kfileptr++); if (!lnumcomponents) { Xfree(dctbuf); return -1; }
if (lnumcomponents > 1) kcoltype = 2; if (lnumcomponents > 1) kcoltype = 2;
for (z=0; z<lnumcomponents; z++) for (z=0; z<lnumcomponents; z++)
{ {
@ -1607,7 +1607,7 @@ static int32_t kpegrend(const char *kfilebuf, int32_t kfilength,
kplib_yrbrend_func(x,y,&dct[0][0]); kplib_yrbrend_func(x,y,&dct[0][0]);
} }
Bfree(dctbuf); return 0; Xfree(dctbuf); return 0;
} }
//============================== KPEGILIB ends ============================== //============================== KPEGILIB ends ==============================
@ -3049,7 +3049,7 @@ void kpzdecode(int32_t const leng, intptr_t * const pic, int32_t * const xsiz, i
if (kprender(kpzbuf, leng, *pic, ((*xsiz)<<2), *xsiz, *ysiz) < 0) if (kprender(kpzbuf, leng, *pic, ((*xsiz)<<2), *xsiz, *ysiz) < 0)
{ {
Bfree((void *) *pic); Xfree((void *) *pic);
*pic = (intptr_t)NULL; *pic = (intptr_t)NULL;
} }
} }

View file

@ -87,7 +87,7 @@ static int32_t read_whole_file(const char *fn, char **retbufptr)
if (i != flen) if (i != flen)
{ {
Bfree(buf); Xfree(buf);
return 2; return 2;
} }
@ -247,6 +247,6 @@ int L_RunOnce(L_State *estate, const char *fn)
return i; return i;
int const retval = L_RunString(estate, buf, -1, fn); int const retval = L_RunString(estate, buf, -1, fn);
Bfree(buf); Xfree(buf);
return retval; return retval;
} }

View file

@ -480,7 +480,7 @@ int32_t md_defineskin(int32_t modelid, const char *skinfn, int32_t palnum, int32
if (!skl) m->skinmap = sk; if (!skl) m->skinmap = sk;
else skl->next = sk; else skl->next = sk;
} }
else Bfree(sk->fn); else Xfree(sk->fn);
sk->palette = (uint8_t)palnum; sk->palette = (uint8_t)palnum;
sk->flags = (uint8_t)flags; sk->flags = (uint8_t)flags;
@ -732,7 +732,7 @@ FHardwareTexture *mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t
{ {
if (kprender(kpzbuf,picfillen,(intptr_t)pic,bytesperline,siz.x,siz.y)) if (kprender(kpzbuf,picfillen,(intptr_t)pic,bytesperline,siz.x,siz.y))
{ {
Bfree(pic); Xfree(pic);
return mdloadskin_failed(skinfile, fn); return mdloadskin_failed(skinfile, fn);
} }
} }
@ -750,7 +750,7 @@ FHardwareTexture *mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t
} }
else if (lastsize < siz.x*siz.y) else if (lastsize < siz.x*siz.y)
{ {
Bfree(lastpic); Xfree(lastpic);
lastpic = (coltype *)Xmalloc(siz.x*siz.y*sizeof(coltype)); lastpic = (coltype *)Xmalloc(siz.x*siz.y*sizeof(coltype));
} }
if (lastpic) if (lastpic)
@ -859,7 +859,7 @@ FHardwareTexture *mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t
(onebitalpha ? DAMETH_ONEBITALPHA : 0) | (onebitalpha ? DAMETH_ONEBITALPHA : 0) |
(hasalpha ? DAMETH_HASALPHA : 0)); (hasalpha ? DAMETH_HASALPHA : 0));
Bfree(pic); Xfree(pic);
} }
if (!m->skinloaded) if (!m->skinloaded)
@ -1107,7 +1107,7 @@ static md2model_t *md2load(buildvfs_kfd fil, const char *filnam)
head.ofseof = B_LITTLE32(head.ofseof); head.ofseof = B_LITTLE32(head.ofseof);
#endif #endif
if ((head.id != IDP2_MAGIC) || (head.vers != 8)) { Bfree(m); return 0; } //"IDP2" if ((head.id != IDP2_MAGIC) || (head.vers != 8)) { Xfree(m); return 0; } //"IDP2"
ournumskins = head.numskins ? head.numskins : 1; ournumskins = head.numskins ? head.numskins : 1;
ournumglcmds = head.numglcmds ? head.numglcmds : 1; ournumglcmds = head.numglcmds ? head.numglcmds : 1;
@ -1125,22 +1125,22 @@ static md2model_t *md2load(buildvfs_kfd fil, const char *filnam)
klseek(fil,head.ofsframes,SEEK_SET); klseek(fil,head.ofsframes,SEEK_SET);
if (kread(fil,(char *)m->frames,m->numframes*m->framebytes) != m->numframes*m->framebytes) if (kread(fil,(char *)m->frames,m->numframes*m->framebytes) != m->numframes*m->framebytes)
{ Bfree(m->uv); Bfree(m->tris); Bfree(m->glcmds); Bfree(m->frames); Bfree(m); return 0; } { Xfree(m->uv); Xfree(m->tris); Xfree(m->glcmds); Xfree(m->frames); Xfree(m); return 0; }
if (m->numglcmds > 0) if (m->numglcmds > 0)
{ {
klseek(fil,head.ofsglcmds,SEEK_SET); klseek(fil,head.ofsglcmds,SEEK_SET);
if (kread(fil,(char *)m->glcmds,m->numglcmds*sizeof(int32_t)) != (int32_t)(m->numglcmds*sizeof(int32_t))) if (kread(fil,(char *)m->glcmds,m->numglcmds*sizeof(int32_t)) != (int32_t)(m->numglcmds*sizeof(int32_t)))
{ Bfree(m->uv); Bfree(m->tris); Bfree(m->glcmds); Bfree(m->frames); Bfree(m); return 0; } { Xfree(m->uv); Xfree(m->tris); Xfree(m->glcmds); Xfree(m->frames); Xfree(m); return 0; }
} }
klseek(fil,head.ofstris,SEEK_SET); klseek(fil,head.ofstris,SEEK_SET);
if (kread(fil,(char *)m->tris,head.numtris*sizeof(md2tri_t)) != (int32_t)(head.numtris*sizeof(md2tri_t))) if (kread(fil,(char *)m->tris,head.numtris*sizeof(md2tri_t)) != (int32_t)(head.numtris*sizeof(md2tri_t)))
{ Bfree(m->uv); Bfree(m->tris); Bfree(m->glcmds); Bfree(m->frames); Bfree(m); return 0; } { Xfree(m->uv); Xfree(m->tris); Xfree(m->glcmds); Xfree(m->frames); Xfree(m); return 0; }
klseek(fil,head.ofsuv,SEEK_SET); klseek(fil,head.ofsuv,SEEK_SET);
if (kread(fil,(char *)m->uv,head.numuv*sizeof(md2uv_t)) != (int32_t)(head.numuv*sizeof(md2uv_t))) if (kread(fil,(char *)m->uv,head.numuv*sizeof(md2uv_t)) != (int32_t)(head.numuv*sizeof(md2uv_t)))
{ Bfree(m->uv); Bfree(m->tris); Bfree(m->glcmds); Bfree(m->frames); Bfree(m); return 0; } { Xfree(m->uv); Xfree(m->tris); Xfree(m->glcmds); Xfree(m->frames); Xfree(m); return 0; }
#if B_BIG_ENDIAN != 0 #if B_BIG_ENDIAN != 0
{ {
@ -1190,7 +1190,7 @@ static md2model_t *md2load(buildvfs_kfd fil, const char *filnam)
{ {
klseek(fil,head.ofsskins,SEEK_SET); klseek(fil,head.ofsskins,SEEK_SET);
if (kread(fil,m->skinfn,64*m->numskins) != 64*m->numskins) if (kread(fil,m->skinfn,64*m->numskins) != 64*m->numskins)
{ Bfree(m->glcmds); Bfree(m->frames); Bfree(m); return 0; } { Xfree(m->glcmds); Xfree(m->frames); Xfree(m); return 0; }
} }
m->texid = (FHardwareTexture **)Xcalloc(ournumskins, sizeof(FHardwareTexture*) * HICTINT_MEMORY_COMBINATIONS); m->texid = (FHardwareTexture **)Xcalloc(ournumskins, sizeof(FHardwareTexture*) * HICTINT_MEMORY_COMBINATIONS);
@ -1317,7 +1317,7 @@ static md2model_t *md2load(buildvfs_kfd fil, const char *filnam)
m3->maxdepths = (float *)Xmalloc(sizeof(float) * s->numtris); m3->maxdepths = (float *)Xmalloc(sizeof(float) * s->numtris);
// die MD2 ! DIE ! // die MD2 ! DIE !
Bfree(m->texid); Bfree(m->skinfn); Bfree(m->basepath); Bfree(m->uv); Bfree(m->tris); Bfree(m->glcmds); Bfree(m->frames); Bfree(m); Xfree(m->texid); Xfree(m->skinfn); Xfree(m->basepath); Xfree(m->uv); Xfree(m->tris); Xfree(m->glcmds); Xfree(m->frames); Xfree(m);
return ((md2model_t *)m3); return ((md2model_t *)m3);
} }
@ -1385,7 +1385,7 @@ static md3model_t *md3load(buildvfs_kfd fil)
m->head.eof = B_LITTLE32(m->head.eof); m->head.eof = B_LITTLE32(m->head.eof);
#endif #endif
if ((m->head.id != IDP3_MAGIC) && (m->head.vers != 15)) { Bfree(m); return 0; } //"IDP3" if ((m->head.id != IDP3_MAGIC) && (m->head.vers != 15)) { Xfree(m); return 0; } //"IDP3"
m->numskins = m->head.numskins; //<- dead code? m->numskins = m->head.numskins; //<- dead code?
m->numframes = m->head.numframes; m->numframes = m->head.numframes;
@ -2281,13 +2281,13 @@ static void md3free(md3model_t *m)
for (anim=m->animations; anim; anim=nanim) for (anim=m->animations; anim; anim=nanim)
{ {
nanim = anim->next; nanim = anim->next;
Bfree(anim); Xfree(anim);
} }
for (sk=m->skinmap; sk; sk=nsk) for (sk=m->skinmap; sk; sk=nsk)
{ {
nsk = sk->next; nsk = sk->next;
Bfree(sk->fn); Xfree(sk->fn);
Bfree(sk); Xfree(sk);
} }
if (m->head.surfs) if (m->head.surfs)
@ -2295,23 +2295,23 @@ static void md3free(md3model_t *m)
for (bssize_t surfi=m->head.numsurfs-1; surfi>=0; surfi--) for (bssize_t surfi=m->head.numsurfs-1; surfi>=0; surfi--)
{ {
md3surf_t *s = &m->head.surfs[surfi]; md3surf_t *s = &m->head.surfs[surfi];
Bfree(s->tris); Xfree(s->tris);
Bfree(s->geometry); // FREE_SURFS_GEOMETRY Xfree(s->geometry); // FREE_SURFS_GEOMETRY
} }
Bfree(m->head.surfs); Xfree(m->head.surfs);
} }
Bfree(m->head.tags); Xfree(m->head.tags);
Bfree(m->head.frames); Xfree(m->head.frames);
Bfree(m->texid); Xfree(m->texid);
Bfree(m->muladdframes); Xfree(m->muladdframes);
Bfree(m->indexes); Xfree(m->indexes);
Bfree(m->vindexes); Xfree(m->vindexes);
Bfree(m->maxdepths); Xfree(m->maxdepths);
Bfree(m); Xfree(m);
} }
//---------------------------------------- MD3 LIBRARY ENDS ---------------------------------------- //---------------------------------------- MD3 LIBRARY ENDS ----------------------------------------

View file

@ -184,7 +184,7 @@ int OSD_Exec(const char *szScript)
if (handle != buildvfs_kfd_invalid) if (handle != buildvfs_kfd_invalid)
kclose(handle); kclose(handle);
Bfree(buf); Xfree(buf);
return 1; return 1;
} }
@ -201,7 +201,7 @@ int OSD_Exec(const char *szScript)
} }
--osd->execdepth; --osd->execdepth;
Bfree(buf); Xfree(buf);
return 0; return 0;
} }
@ -313,7 +313,7 @@ static int osdfunc_fileinfo(osdcmdptr_t parm)
uint32_t const xxhash = XXH32_digest(&xxh); uint32_t const xxhash = XXH32_digest(&xxh);
xxhtime = timerGetTicks() - xxhtime; xxhtime = timerGetTicks() - xxhtime;
Bfree(buf); Xfree(buf);
OSD_Printf("fileinfo: %s\n" OSD_Printf("fileinfo: %s\n"
" File size: %d\n" " File size: %d\n"
@ -1430,10 +1430,10 @@ void OSD_ResizeDisplay(int w, int h)
Bmemcpy(newfmt + newcols * i, t.fmt + d.cols * i, copycols); Bmemcpy(newfmt + newcols * i, t.fmt + d.cols * i, copycols);
} }
Bfree(t.buf); Xfree(t.buf);
t.buf = newtext; t.buf = newtext;
Bfree(t.fmt); Xfree(t.fmt);
t.fmt = newfmt; t.fmt = newfmt;
t.maxlines = newmaxlines; t.maxlines = newmaxlines;
@ -1649,7 +1649,7 @@ void OSD_Puts(const char *tmpstr)
char *chp2 = Xstrdup(tmpstr); char *chp2 = Xstrdup(tmpstr);
buildvfs_fputs(OSD_StripColors(chp2, tmpstr), osdlog); buildvfs_fputs(OSD_StripColors(chp2, tmpstr), osdlog);
Bprintf("%s", chp2); Bprintf("%s", chp2);
Bfree(chp2); Xfree(chp2);
} }
else if (log.lines == log.cutoff) else if (log.lines == log.cutoff)
{ {
@ -1860,7 +1860,7 @@ void OSD_Dispatch(const char *cmd)
// cheap hack for comments in cfgs // cheap hack for comments in cfgs
if (token[0] == '/' && token[1] == '/') if (token[0] == '/' && token[1] == '/')
{ {
Bfree(workbuf); Xfree(workbuf);
return; return;
} }
@ -1877,7 +1877,7 @@ void OSD_Dispatch(const char *cmd)
else if (m32_osd_tryscript) else if (m32_osd_tryscript)
M32RunScript(cmd); M32RunScript(cmd);
Bfree(workbuf); Xfree(workbuf);
return; return;
} }
@ -1909,7 +1909,7 @@ void OSD_Dispatch(const char *cmd)
} }
while (wtp && restart); while (wtp && restart);
Bfree(workbuf); Xfree(workbuf);
} }
@ -1992,7 +1992,7 @@ static osdsymbol_t *osd_addsymbol(const char *pszName)
hash_add(&h_osd, pszName, osd->numsymbols, 1); hash_add(&h_osd, pszName, osd->numsymbols, 1);
hash_add(&h_osd, lowercase, osd->numsymbols, 1); hash_add(&h_osd, lowercase, osd->numsymbols, 1);
Bfree(lowercase); Xfree(lowercase);
osd->symbptrs[osd->numsymbols++] = newsymb; osd->symbptrs[osd->numsymbols++] = newsymb;
@ -2036,7 +2036,7 @@ static osdsymbol_t * osd_findexactsymbol(const char *pszName)
char *const lname = Xstrdup(pszName); char *const lname = Xstrdup(pszName);
Bstrtolower(lname); Bstrtolower(lname);
symbolNum = hash_find(&h_osd, lname); symbolNum = hash_find(&h_osd, lname);
Bfree(lname); Xfree(lname);
} }
return (symbolNum >= 0) ? osd->symbptrs[symbolNum] : NULL; return (symbolNum >= 0) ? osd->symbptrs[symbolNum] : NULL;

View file

@ -331,7 +331,7 @@ void paletteLoadFromDisk(void)
if (kread_and_test(fil, &blendnum, 1)) if (kread_and_test(fil, &blendnum, 1))
{ {
initprintf("Warning: failed reading additional blending table index\n"); initprintf("Warning: failed reading additional blending table index\n");
Bfree(tab); Xfree(tab);
return kclose(fil); return kclose(fil);
} }
@ -341,13 +341,13 @@ void paletteLoadFromDisk(void)
if (kread_and_test(fil, tab, 256*256)) if (kread_and_test(fil, tab, 256*256))
{ {
initprintf("Warning: failed reading additional blending table\n"); initprintf("Warning: failed reading additional blending table\n");
Bfree(tab); Xfree(tab);
return kclose(fil); return kclose(fil);
} }
paletteSetBlendTable(blendnum, tab); paletteSetBlendTable(blendnum, tab);
} }
Bfree(tab); Xfree(tab);
// Read log2 of count of alpha blending tables. // Read log2 of count of alpha blending tables.
uint8_t lognumalphatabs; uint8_t lognumalphatabs;

View file

@ -34,7 +34,7 @@ static void png_write_chunk(uint32_t const size, char const *const type,
crc = Bcrc32(chunk, chunk_size + 4, crc); crc = Bcrc32(chunk, chunk_size + 4, crc);
png_write_uint32(crc); png_write_uint32(crc);
Bfree(chunk); Xfree(chunk);
} }
void png_set_pal(uint8_t const * const data, int numentries) void png_set_pal(uint8_t const * const data, int numentries)
@ -93,5 +93,5 @@ void png_write(buildvfs_FILE const file, int const width, int const height,
png_write_chunk(linesiz, "IDAT", lines, CHUNK_COMPRESSED); png_write_chunk(linesiz, "IDAT", lines, CHUNK_COMPRESSED);
png_write_chunk(0, "IEND", NULL, 0); png_write_chunk(0, "IEND", NULL, 0);
Bfree(lines); Xfree(lines);
} }

View file

@ -445,11 +445,11 @@ void polymost_glreset()
if (pth->flags & PTH_HASFULLBRIGHT) if (pth->flags & PTH_HASFULLBRIGHT)
{ {
delete pth->ofb->glpic; delete pth->ofb->glpic;
Bfree(pth->ofb); Xfree(pth->ofb);
} }
delete pth->glpic; delete pth->glpic;
Bfree(pth); Xfree(pth);
pth = next; pth = next;
} }
@ -1781,7 +1781,7 @@ void gloadtile_art(int32_t dapic, int32_t dapal, int32_t tintpalnum, int32_t das
(npoty ? DAMETH_NPOTWALL : 0) | (npoty ? DAMETH_NPOTWALL : 0) |
(hasalpha ? (DAMETH_HASALPHA|DAMETH_ONEBITALPHA) : 0)); (hasalpha ? (DAMETH_HASALPHA|DAMETH_ONEBITALPHA) : 0));
Bfree(pic); Xfree(pic);
} }
polymost_setuptexture(pth->glpic, dameth, -1); polymost_setuptexture(pth->glpic, dameth, -1);
@ -1916,7 +1916,7 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp
{ {
if (kprender(kpzbuf,picfillen,(intptr_t)pic,bytesperline,siz.x,siz.y)) if (kprender(kpzbuf,picfillen,(intptr_t)pic,bytesperline,siz.x,siz.y))
{ {
Bfree(pic); Xfree(pic);
return -2; return -2;
} }
} }
@ -1934,7 +1934,7 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp
} }
else if (lastsize < siz.x*siz.y) else if (lastsize < siz.x*siz.y)
{ {
Bfree(lastpic); Xfree(lastpic);
lastpic = (coltype *)Xmalloc(siz.x*siz.y*sizeof(coltype)); lastpic = (coltype *)Xmalloc(siz.x*siz.y*sizeof(coltype));
} }
if (lastpic) if (lastpic)
@ -2057,7 +2057,7 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp
(onebitalpha ? DAMETH_ONEBITALPHA : 0) | (onebitalpha ? DAMETH_ONEBITALPHA : 0) |
(hasalpha ? DAMETH_HASALPHA : 0)); (hasalpha ? DAMETH_HASALPHA : 0));
Bfree(pic); Xfree(pic);
} }
// precalculate scaling parameters for replacement // precalculate scaling parameters for replacement
@ -7370,7 +7370,7 @@ static int32_t gen_font_glyph_tex(void)
polymosttext->CreateTexture(256, 128, false, false); polymosttext->CreateTexture(256, 128, false, false);
polymosttext->LoadTexture((uint8_t*)tbuf); // RGBA polymosttext->LoadTexture((uint8_t*)tbuf); // RGBA
polymosttext->SetSampler(Sampler2DNoFilter); polymosttext->SetSampler(Sampler2DNoFilter);
Bfree(tbuf); Xfree(tbuf);
return 0; return 0;
} }

View file

@ -44,7 +44,7 @@ static void screencapture_end(char *fn, buildvfs_FILE * filptr)
{ {
buildvfs_fclose(*filptr); buildvfs_fclose(*filptr);
OSD_Printf("Saved screenshot to %s\n", fn); OSD_Printf("Saved screenshot to %s\n", fn);
Bfree(fn); Xfree(fn);
capturecounter.count++; capturecounter.count++;
} }
@ -61,7 +61,7 @@ int videoCaptureScreen(const char *filename, char inverseit)
if (fp == nullptr) if (fp == nullptr)
{ {
Bfree(fn); Xfree(fn);
return -1; return -1;
} }
@ -91,7 +91,7 @@ int videoCaptureScreen(const char *filename, char inverseit)
Bmemcpy(imgBuf + (ydim - i - 1) * bytesPerLine, rowBuf, bytesPerLine); Bmemcpy(imgBuf + (ydim - i - 1) * bytesPerLine, rowBuf, bytesPerLine);
} }
Bfree(rowBuf); Xfree(rowBuf);
} }
else else
#endif #endif
@ -125,7 +125,7 @@ int videoCaptureScreen(const char *filename, char inverseit)
png_set_text("Software", osd->version.buf); png_set_text("Software", osd->version.buf);
png_write(fp, xdim, ydim, HICOLOR ? PNG_TRUECOLOR : PNG_INDEXED, imgBuf); png_write(fp, xdim, ydim, HICOLOR ? PNG_TRUECOLOR : PNG_INDEXED, imgBuf);
Bfree(imgBuf); Xfree(imgBuf);
screencapture_end(fn, &fp); screencapture_end(fn, &fp);
return 0; return 0;
@ -141,7 +141,7 @@ int videoCaptureScreenTGA(const char *filename, char inverseit)
buildvfs_FILE fil = capturecounter.opennextfile_withext(fn, "tga"); buildvfs_FILE fil = capturecounter.opennextfile_withext(fn, "tga");
if (fil == nullptr) if (fil == nullptr)
{ {
Bfree(fn); Xfree(fn);
return -1; return -1;
} }
@ -206,7 +206,7 @@ int videoCaptureScreenTGA(const char *filename, char inverseit)
swapchar(&inversebuf[i], &inversebuf[i + 2]); swapchar(&inversebuf[i], &inversebuf[i + 2]);
buildvfs_fwrite(inversebuf, xdim*ydim, 3, fil); buildvfs_fwrite(inversebuf, xdim*ydim, 3, fil);
Bfree(inversebuf); Xfree(inversebuf);
} }
else else
# endif # endif

View file

@ -341,10 +341,10 @@ scriptfile *scriptfile_fromstring(const char *string)
void scriptfile_close(scriptfile *sf) void scriptfile_close(scriptfile *sf)
{ {
if (!sf) return; if (!sf) return;
Bfree(sf->lineoffs); Xfree(sf->lineoffs);
Bfree(sf->textbuf); Xfree(sf->textbuf);
Bfree(sf->filename); Xfree(sf->filename);
Bfree(sf); Xfree(sf);
} }
int scriptfile_eof(scriptfile *sf) int scriptfile_eof(scriptfile *sf)

View file

@ -14,7 +14,7 @@
#define CLEAR_GL_ERRORS() while(glGetError() != GL_NO_ERROR) { } #define CLEAR_GL_ERRORS() while(glGetError() != GL_NO_ERROR) { }
#define TEXCACHE_FREEBUFS() { Bfree(pic), Bfree(packbuf), Bfree(midbuf); } #define TEXCACHE_FREEBUFS() { Xfree(pic), Xfree(packbuf), Xfree(midbuf); }
globaltexcache texcache; globaltexcache texcache;
@ -193,7 +193,7 @@ pthtyp *texcache_fetch(int32_t dapicnum, int32_t dapalnum, int32_t dashade, int3
if (tilestat == -2) // bad filename if (tilestat == -2) // bad filename
hicclearsubst(dapicnum, dapalnum); hicclearsubst(dapicnum, dapalnum);
Bfree(pth); Xfree(pth);
return (drawingskybox || hicprecaching) ? NULL : texcache_tryart(dapicnum, dapalnum, dashade, dameth); return (drawingskybox || hicprecaching) ? NULL : texcache_tryart(dapicnum, dapalnum, dashade, dameth);
} }

View file

@ -760,12 +760,12 @@ int32_t tileCRC(int16_t tileNum)
if (dasiz <= 0) if (dasiz <= 0)
return 0; return 0;
data = (char *)Bmalloc(dasiz); data = (char *)Xmalloc(dasiz);
tileLoadData(tileNum, dasiz, data); tileLoadData(tileNum, dasiz, data);
int32_t crc = Bcrc32((unsigned char *)data, (unsigned int)dasiz, 0); int32_t crc = Bcrc32((unsigned char *)data, (unsigned int)dasiz, 0);
Bfree(data); Xfree(data);
return crc; return crc;
} }

View file

@ -76,7 +76,7 @@ FHardwareTexture *gloadtex(const int32_t *picbuf, int32_t xsiz, int32_t ysiz, in
tex->CreateTexture(xsiz, ysiz, false, false); tex->CreateTexture(xsiz, ysiz, false, false);
tex->LoadTexture((uint8_t*)pic2); // RGBA tex->LoadTexture((uint8_t*)pic2); // RGBA
tex->SetSampler(SamplerNoFilter); tex->SetSampler(SamplerNoFilter);
Bfree(pic2); Xfree(pic2);
return tex; return tex;
} }
@ -534,7 +534,7 @@ skindidntfit:
i--; i--;
if (i < 0) //Time-out! Very slow if this happens... but at least it still works :P if (i < 0) //Time-out! Very slow if this happens... but at least it still works :P
{ {
Bfree(zbit); Xfree(zbit);
//Re-generate shp[].x/y (box sizes) from shcnt (now head indices) for next pass :/ //Re-generate shp[].x/y (box sizes) from shcnt (now head indices) for next pass :/
j = 0; j = 0;
@ -578,7 +578,7 @@ skindidntfit:
} }
} }
Bfree(shp); Bfree(zbit); Bfree(bx0); Xfree(shp); Xfree(zbit); Xfree(bx0);
return gvox; return gvox;
} }
@ -681,7 +681,7 @@ static int32_t loadvox(const char *filnam)
} }
} }
Bfree(tbuf); Xfree(tbuf);
kclose(fil); kclose(fil);
return 0; return 0;
@ -766,8 +766,8 @@ static int32_t loadkvx(const char *filnam)
} }
} }
Bfree(tbuf); Xfree(tbuf);
Bfree(xyoffs); Xfree(xyoffs);
return 0; return 0;
} }
@ -840,7 +840,7 @@ static int32_t loadkv6(const char *filnam)
} }
} }
Bfree(ylen); Xfree(ylen);
kclose(fil); kclose(fil);
return 0; return 0;
@ -855,7 +855,7 @@ void voxfree(voxmodel_t *m)
DO_FREE_AND_NULL(m->quad); DO_FREE_AND_NULL(m->quad);
DO_FREE_AND_NULL(m->texid); DO_FREE_AND_NULL(m->texid);
Bfree(m); Xfree(m);
} }
voxmodel_t *voxload(const char *filnam) voxmodel_t *voxload(const char *filnam)

View file

@ -113,7 +113,7 @@ static void win_printversion(void)
} }
initprintf("Running on %s (build %lu.%lu.%lu)\n", str, osv.dwMajorVersion, osv.dwMinorVersion, osv.dwBuildNumber); initprintf("Running on %s (build %lu.%lu.%lu)\n", str, osv.dwMajorVersion, osv.dwMinorVersion, osv.dwBuildNumber);
Bfree(str); Xfree(str);
} }
// //
@ -344,7 +344,7 @@ int32_t addsearchpath_ProgramFiles(const char *p)
Bsprintf(buffer,"%s/%s",ProgramFiles[i],p); Bsprintf(buffer,"%s/%s",ProgramFiles[i],p);
if (addsearchpath(buffer) == 0) // if any work, return success if (addsearchpath(buffer) == 0) // if any work, return success
returncode = 0; returncode = 0;
Bfree(buffer); Xfree(buffer);
} }
} }

View file

@ -410,7 +410,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nC
win_close(); win_close();
Bfree(argvbuf); Xfree(argvbuf);
return r; return r;
} }
@ -1074,17 +1074,17 @@ static void UninitDirectInput(void)
if (axisdefs) if (axisdefs)
{ {
for (i=joystick.numAxes-1; i>=0; i--) Bfree(axisdefs[i].name); for (i=joystick.numAxes-1; i>=0; i--) Xfree(axisdefs[i].name);
DO_FREE_AND_NULL(axisdefs); DO_FREE_AND_NULL(axisdefs);
} }
if (buttondefs) if (buttondefs)
{ {
for (i=joystick.numButtons-1; i>=0; i--) Bfree(buttondefs[i].name); for (i=joystick.numButtons-1; i>=0; i--) Xfree(buttondefs[i].name);
DO_FREE_AND_NULL(buttondefs); DO_FREE_AND_NULL(buttondefs);
} }
if (hatdefs) if (hatdefs)
{ {
for (i=joystick.numHats-1; i>=0; i--) Bfree(hatdefs[i].name); for (i=joystick.numHats-1; i>=0; i--) Xfree(hatdefs[i].name);
DO_FREE_AND_NULL(hatdefs); DO_FREE_AND_NULL(hatdefs);
} }
@ -2039,7 +2039,7 @@ int32_t videoUpdatePalette(int32_t start, int32_t num)
} }
SetDIBColorTable(hDCSection, start, num, rgb); SetDIBColorTable(hDCSection, start, num, rgb);
Bfree(rgb); Xfree(rgb);
} }
return 0; return 0;
@ -2923,7 +2923,7 @@ static int32_t SetupOpenGL(int32_t width, int32_t height, int32_t bitspp)
glinfo.sync = 1; glinfo.sync = 1;
} }
} }
Bfree(p); Xfree(p);
} }
numpages = 2; // KJS 20031225: tell rotatesprite that it's double buffered! numpages = 2; // KJS 20031225: tell rotatesprite that it's double buffered!

View file

@ -60,7 +60,7 @@ dukeanim_t *Anim_Find(const char *s)
ptr = hash_findcase(&h_dukeanim, str); ptr = hash_findcase(&h_dukeanim, str);
} }
Bfree(str); Xfree(str);
} }
return (dukeanim_t *)(ptr == -1 ? NULL : (dukeanim_t *)ptr); return (dukeanim_t *)(ptr == -1 ? NULL : (dukeanim_t *)ptr);

View file

@ -1746,7 +1746,7 @@ static int32_t sort_sounds(int32_t how)
{ {
case 'g': // restore original order case 'g': // restore original order
Bmemcpy(g_sndnum, g_definedsndnum, sizeof(int16_t)*n); Bmemcpy(g_sndnum, g_definedsndnum, sizeof(int16_t)*n);
Bfree(dst); Xfree(dst);
return 0; return 0;
case 's': case 's':
compare_sounds = compare_sounds_s; compare_sounds = compare_sounds_s;
@ -1773,7 +1773,7 @@ static int32_t sort_sounds(int32_t how)
compare_sounds = compare_sounds_5; compare_sounds = compare_sounds_5;
break; break;
default: default:
Bfree(dst); Xfree(dst);
return -2; return -2;
} }
@ -1815,7 +1815,7 @@ static int32_t sort_sounds(int32_t how)
if (src != source) if (src != source)
Bmemcpy(source, src, sizeof(int16_t) * n); Bmemcpy(source, src, sizeof(int16_t) * n);
Bfree(dest); Xfree(dest);
return 0; return 0;
} }
@ -4166,7 +4166,7 @@ ERROR_TOOMANYSPRITES:
if (cursor < 0) message("Too many sprites in map!"); if (cursor < 0) message("Too many sprites in map!");
else deletesprite(cursor); else deletesprite(cursor);
Bfree(spritenums); Xfree(spritenums);
clearkeys(); clearkeys();
@ -8482,7 +8482,7 @@ static void G_CheckCommandLine(int32_t argc, char const * const * argv)
i++; i++;
} }
Bfree(lengths); Xfree(lengths);
if (j > 0) if (j > 0)
{ {
@ -8998,7 +8998,7 @@ static void SaveInHistory(const char *commandstr)
if (dosave) if (dosave)
{ {
Bfree(scripthist[scripthistend]); Xfree(scripthist[scripthistend]);
scripthist[scripthistend] = Xstrdup(commandstr); scripthist[scripthistend] = Xstrdup(commandstr);
scripthistend++; scripthistend++;
scripthistend %= SCRIPTHISTSIZ; scripthistend %= SCRIPTHISTSIZ;
@ -9109,7 +9109,7 @@ static int osdcmd_do(osdcmdptr_t parm)
if (g_numCompilerErrors) if (g_numCompilerErrors)
{ {
// g_scriptPtr = script + oscrofs; // handled in C_Compile() // g_scriptPtr = script + oscrofs; // handled in C_Compile()
Bfree(tp); Xfree(tp);
return OSDCMD_OK; return OSDCMD_OK;
} }
@ -9720,8 +9720,8 @@ static int32_t loadtilegroups(const char *fn)
for (i=0; i<tile_groups; i++) for (i=0; i<tile_groups; i++)
{ {
Bfree(s_TileGroups[i].pIds); Xfree(s_TileGroups[i].pIds);
Bfree(s_TileGroups[i].szText); Xfree(s_TileGroups[i].szText);
Bmemcpy(&s_TileGroups[i], &blank, sizeof(blank)); Bmemcpy(&s_TileGroups[i], &blank, sizeof(blank));
} }
tile_groups = 0; tile_groups = 0;
@ -9872,14 +9872,14 @@ static int32_t parseconsounds(scriptfile *script)
{ {
initprintf("Warning: invalid sound definition %s (sound number < 0 or >= MAXSOUNDS) on line %s:%d\n", initprintf("Warning: invalid sound definition %s (sound number < 0 or >= MAXSOUNDS) on line %s:%d\n",
definedname, script->filename,scriptfile_getlinum(script,cmdtokptr)); definedname, script->filename,scriptfile_getlinum(script,cmdtokptr));
Bfree(definedname); Xfree(definedname);
num_invalidsounds++; num_invalidsounds++;
break; break;
} }
if (scriptfile_getstring(script, &filename)) if (scriptfile_getstring(script, &filename))
{ {
Bfree(definedname); Xfree(definedname);
num_invalidsounds++; num_invalidsounds++;
break; break;
} }
@ -9889,7 +9889,7 @@ static int32_t parseconsounds(scriptfile *script)
{ {
initprintf("Warning: invalid sound definition %s (filename too long) on line %s:%d\n", initprintf("Warning: invalid sound definition %s (filename too long) on line %s:%d\n",
definedname, script->filename,scriptfile_getlinum(script,cmdtokptr)); definedname, script->filename,scriptfile_getlinum(script,cmdtokptr));
Bfree(definedname); Xfree(definedname);
num_invalidsounds++; num_invalidsounds++;
break; break;
} }
@ -9897,7 +9897,7 @@ static int32_t parseconsounds(scriptfile *script)
if (g_sounds[sndnum].filename) if (g_sounds[sndnum].filename)
{ {
duplicate = 1; duplicate = 1;
Bfree(g_sounds[sndnum].filename); Xfree(g_sounds[sndnum].filename);
} }
g_sounds[sndnum].filename = (char *)Xcalloc(slen+1,sizeof(uint8_t)); g_sounds[sndnum].filename = (char *)Xcalloc(slen+1,sizeof(uint8_t));
// Hopefully noone does memcpy(..., g_sounds[].filename, BMAX_PATH) // Hopefully noone does memcpy(..., g_sounds[].filename, BMAX_PATH)
@ -9913,7 +9913,7 @@ static int32_t parseconsounds(scriptfile *script)
if (0) if (0)
{ {
BAD: BAD:
Bfree(definedname); Xfree(definedname);
DO_FREE_AND_NULL(g_sounds[sndnum].filename); DO_FREE_AND_NULL(g_sounds[sndnum].filename);
num_invalidsounds++; num_invalidsounds++;
break; break;
@ -9922,7 +9922,7 @@ BAD:
if (g_sounds[sndnum].definedname) if (g_sounds[sndnum].definedname)
{ {
duplicate = 1; duplicate = 1;
Bfree(g_sounds[sndnum].definedname); Xfree(g_sounds[sndnum].definedname);
} }
if (duplicate) if (duplicate)
initprintf("warning: duplicate sound #%d, overwriting\n", sndnum); initprintf("warning: duplicate sound #%d, overwriting\n", sndnum);
@ -10055,7 +10055,7 @@ int32_t ExtInit(void)
Bsprintf(tempbuf, "m32_settings.cfg"); Bsprintf(tempbuf, "m32_settings.cfg");
else Bsprintf(tempbuf,"%s_m32_settings.cfg",p); else Bsprintf(tempbuf,"%s_m32_settings.cfg",p);
OSD_Exec(tempbuf); OSD_Exec(tempbuf);
Bfree(ptr); Xfree(ptr);
} }
// backup pathsearchmode so that a later open // backup pathsearchmode so that a later open
@ -10138,11 +10138,11 @@ void ExtUnInit(void)
#if 0 #if 0
for (i = MAX_TILE_GROUPS-1; i >= 0; i--) for (i = MAX_TILE_GROUPS-1; i >= 0; i--)
{ {
Bfree(s_TileGroups[i].pIds); Xfree(s_TileGroups[i].pIds);
Bfree(s_TileGroups[i].szText); Xfree(s_TileGroups[i].szText);
} }
for (i = numhelppages-1; i >= 0; i--) Bfree(helppage[i]); for (i = numhelppages-1; i >= 0; i--) Xfree(helppage[i]);
Bfree(helppage); Xfree(helppage);
#endif #endif
Duke_CommonCleanup(); Duke_CommonCleanup();
@ -10684,7 +10684,7 @@ static void Keys2d3d(void)
{ {
// map_revision = 0; // map_revision = 0;
create_map_snapshot(); // initial map state create_map_snapshot(); // initial map state
// Bfree(mapstate->next); // Xfree(mapstate->next);
// mapstate = mapstate->prev; // mapstate = mapstate->prev;
} }
#endif #endif

View file

@ -55,13 +55,13 @@ char *g_rtsNamePtr = NULL;
void clearGrpNamePtr(void) void clearGrpNamePtr(void)
{ {
Bfree(g_grpNamePtr); Xfree(g_grpNamePtr);
// g_grpNamePtr assumed to be assigned to right after // g_grpNamePtr assumed to be assigned to right after
} }
void clearScriptNamePtr(void) void clearScriptNamePtr(void)
{ {
Bfree(g_scriptNamePtr); Xfree(g_scriptNamePtr);
// g_scriptNamePtr assumed to be assigned to right after // g_scriptNamePtr assumed to be assigned to right after
} }
@ -267,7 +267,7 @@ void G_ExtInit(void)
#ifdef EDUKE32_OSX #ifdef EDUKE32_OSX
char *appdir = Bgetappdir(); char *appdir = Bgetappdir();
addsearchpath(appdir); addsearchpath(appdir);
Bfree(appdir); Xfree(appdir);
#endif #endif
#ifdef USE_PHYSFS #ifdef USE_PHYSFS
@ -292,8 +292,8 @@ void G_ExtInit(void)
i==-1 ? "not a directory" : "no such directory"); i==-1 ? "not a directory" : "no such directory");
} }
Bfree(CommandPaths->str); Xfree(CommandPaths->str);
Bfree(CommandPaths); Xfree(CommandPaths);
CommandPaths = s; CommandPaths = s;
} }
} }
@ -326,7 +326,7 @@ void G_ExtInit(void)
} }
if (asperr == 0) if (asperr == 0)
buildvfs_chdir(cwd); buildvfs_chdir(cwd);
Bfree(homedir); Xfree(homedir);
} }
} }
@ -499,8 +499,8 @@ void G_LoadGroups(int32_t autoload)
G_DoAutoload(CommandGrps->str); G_DoAutoload(CommandGrps->str);
} }
Bfree(CommandGrps->str); Xfree(CommandGrps->str);
Bfree(CommandGrps); Xfree(CommandGrps);
CommandGrps = s; CommandGrps = s;
} }
pathsearchmode = bakpathsearchmode; pathsearchmode = bakpathsearchmode;
@ -759,7 +759,7 @@ static void G_ParseSteamKeyValuesForPaths(const char *vdf)
G_AddSteamPaths(result); G_AddSteamPaths(result);
} }
Bfree(vdfbufstart); Xfree(vdfbufstart);
} }
#endif #endif
#endif #endif
@ -779,7 +779,7 @@ void G_AddSearchPaths(void)
Bsnprintf(buf, sizeof(buf), "%s/.steam/steam/steamapps/libraryfolders.vdf", homepath); Bsnprintf(buf, sizeof(buf), "%s/.steam/steam/steamapps/libraryfolders.vdf", homepath);
G_ParseSteamKeyValuesForPaths(buf); G_ParseSteamKeyValuesForPaths(buf);
Bfree(homepath); Xfree(homepath);
addsearchpath("/usr/share/games/jfduke3d"); addsearchpath("/usr/share/games/jfduke3d");
addsearchpath("/usr/local/share/games/jfduke3d"); addsearchpath("/usr/local/share/games/jfduke3d");
@ -814,8 +814,8 @@ void G_AddSearchPaths(void)
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++)
{ {
Bfree(applications[i]); Xfree(applications[i]);
Bfree(support[i]); Xfree(support[i]);
} }
#elif defined (_WIN32) #elif defined (_WIN32)
char buf[BMAX_PATH] = {0}; char buf[BMAX_PATH] = {0};
@ -1151,11 +1151,11 @@ buildvfs_kfd S_OpenAudio(const char *fn, char searchfirst, uint8_t const ismusic
goto success; goto success;
#endif #endif
Bfree(testfn); Xfree(testfn);
return origfp; return origfp;
success: success:
Bfree(testfn); Xfree(testfn);
kclose(origfp); kclose(origfp);
return fp; return fp;
} }

View file

@ -699,7 +699,7 @@ static void G_ReadGLFrame(void)
} }
} }
Bfree(frame); Xfree(frame);
} }
#endif #endif
@ -5145,7 +5145,7 @@ static void parsedefinitions_game_include(const char *fileName, scriptfile *pScr
static void parsedefinitions_game_animsounds(scriptfile *pScript, const char * blockEnd, char const * fileName, dukeanim_t * animPtr) static void parsedefinitions_game_animsounds(scriptfile *pScript, const char * blockEnd, char const * fileName, dukeanim_t * animPtr)
{ {
Bfree(animPtr->sounds); Xfree(animPtr->sounds);
size_t numPairs = 0, allocSize = 4; size_t numPairs = 0, allocSize = 4;
@ -5563,7 +5563,7 @@ void G_UpdateAppTitle(void)
static void G_FreeHashAnim(const char * /*string*/, intptr_t key) static void G_FreeHashAnim(const char * /*string*/, intptr_t key)
{ {
Bfree((void *)key); Xfree((void *)key);
} }
static void G_Cleanup(void) static void G_Cleanup(void)
@ -5574,36 +5574,36 @@ static void G_Cleanup(void)
for (i=(MAXLEVELS*(MAXVOLUMES+1))-1; i>=0; i--) // +1 volume for "intro", "briefing" music for (i=(MAXLEVELS*(MAXVOLUMES+1))-1; i>=0; i--) // +1 volume for "intro", "briefing" music
{ {
Bfree(g_mapInfo[i].name); Xfree(g_mapInfo[i].name);
Bfree(g_mapInfo[i].filename); Xfree(g_mapInfo[i].filename);
Bfree(g_mapInfo[i].musicfn); Xfree(g_mapInfo[i].musicfn);
G_FreeMapState(i); G_FreeMapState(i);
} }
for (i=MAXQUOTES-1; i>=0; i--) for (i=MAXQUOTES-1; i>=0; i--)
{ {
Bfree(apStrings[i]); Xfree(apStrings[i]);
Bfree(apXStrings[i]); Xfree(apXStrings[i]);
} }
for (i=MAXPLAYERS-1; i>=0; i--) for (i=MAXPLAYERS-1; i>=0; i--)
{ {
Bfree(g_player[i].ps); Xfree(g_player[i].ps);
Bfree(g_player[i].inputBits); Xfree(g_player[i].inputBits);
} }
for (i=MAXSOUNDS-1; i>=0; i--) for (i=MAXSOUNDS-1; i>=0; i--)
{ {
Bfree(g_sounds[i].filename); Xfree(g_sounds[i].filename);
} }
#if !defined LUNATIC #if !defined LUNATIC
if (label != (char *)&sprite[0]) Bfree(label); if (label != (char *)&sprite[0]) Xfree(label);
if (labelcode != (int32_t *)&sector[0]) Bfree(labelcode); if (labelcode != (int32_t *)&sector[0]) Xfree(labelcode);
Bfree(apScript); Xfree(apScript);
Bfree(bitptr); Xfree(bitptr);
// Bfree(MusicPtr); // Xfree(MusicPtr);
Gv_Clear(); Gv_Clear();
@ -5954,7 +5954,7 @@ static void G_Startup(void)
} }
buildvfs_chdir(cwd); buildvfs_chdir(cwd);
#ifndef __ANDROID__ //This crashes on *some* Android devices. Small onetime memory leak. TODO fix above function #ifndef __ANDROID__ //This crashes on *some* Android devices. Small onetime memory leak. TODO fix above function
Bfree(cwd); Xfree(cwd);
#endif #endif
} }
else if (artLoadFiles("tiles%03d.art",MAXCACHE1DSIZE) < 0) else if (artLoadFiles("tiles%03d.art",MAXCACHE1DSIZE) < 0)
@ -6201,7 +6201,7 @@ int app_main(int argc, char const * const * argv)
else else
Bstrcpy(cwd, APPBASENAME ".log"); Bstrcpy(cwd, APPBASENAME ".log");
OSD_SetLogFile(cwd); OSD_SetLogFile(cwd);
Bfree(homedir); Xfree(homedir);
} }
else else
#endif #endif
@ -6511,7 +6511,7 @@ int app_main(int argc, char const * const * argv)
else else
Bsprintf(tempbuf, "%s_settings.cfg", p); Bsprintf(tempbuf, "%s_settings.cfg", p);
Bfree(setupFileName); Xfree(setupFileName);
OSD_Exec(tempbuf); OSD_Exec(tempbuf);
OSD_Exec("autoexec.cfg"); OSD_Exec("autoexec.cfg");

View file

@ -1667,7 +1667,7 @@ static int32_t C_GetNextValue(int32_t type)
{ {
char *gl = C_GetLabelType(labeltype[i]); char *gl = C_GetLabelType(labeltype[i]);
initprintf("%s:%d: debug: %s label `%s'.\n",g_scriptFileName,g_lineNumber,gl,label+(i<<6)); initprintf("%s:%d: debug: %s label `%s'.\n",g_scriptFileName,g_lineNumber,gl,label+(i<<6));
Bfree(gl); Xfree(gl);
} }
scriptWriteValue(labelcode[i]); scriptWriteValue(labelcode[i]);
@ -1683,8 +1683,8 @@ static int32_t C_GetNextValue(int32_t type)
C_ReportError(-1); C_ReportError(-1);
initprintf("%s:%d: warning: expected %s, found %s.\n",g_scriptFileName,g_lineNumber,el,gl); initprintf("%s:%d: warning: expected %s, found %s.\n",g_scriptFileName,g_lineNumber,el,gl);
g_warningCnt++; g_warningCnt++;
Bfree(el); Xfree(el);
Bfree(gl); Xfree(gl);
return -1; // valid label name, but wrong type return -1; // valid label name, but wrong type
} }
@ -1933,7 +1933,7 @@ static void C_Include(const char *confile)
textptr = origtptr; textptr = origtptr;
Bfree(mptr); Xfree(mptr);
} }
#endif // !defined LUNATIC #endif // !defined LUNATIC
@ -2016,7 +2016,7 @@ void C_DefineMusic(int volumeNum, int levelNum, const char *fileName)
map_t *const pMapInfo = &g_mapInfo[(MAXLEVELS*volumeNum)+levelNum]; map_t *const pMapInfo = &g_mapInfo[(MAXLEVELS*volumeNum)+levelNum];
Bfree(pMapInfo->musicfn); Xfree(pMapInfo->musicfn);
pMapInfo->musicfn = dup_filename(fileName); pMapInfo->musicfn = dup_filename(fileName);
check_filename_case(pMapInfo->musicfn); check_filename_case(pMapInfo->musicfn);
} }
@ -2029,7 +2029,7 @@ void C_DefineSound(int32_t sndidx, const char *fn, int32_t args[5])
{ {
sound_t *const snd = &g_sounds[sndidx]; sound_t *const snd = &g_sounds[sndidx];
Bfree(snd->filename); Xfree(snd->filename);
snd->filename = dup_filename(fn); snd->filename = dup_filename(fn);
check_filename_case(snd->filename); check_filename_case(snd->filename);
@ -2076,11 +2076,11 @@ void C_DefineLevelName(int32_t vol, int32_t lev, const char *fn,
{ {
map_t *const map = &g_mapInfo[(MAXLEVELS*vol)+lev]; map_t *const map = &g_mapInfo[(MAXLEVELS*vol)+lev];
Bfree(map->filename); Xfree(map->filename);
map->filename = dup_filename(fn); map->filename = dup_filename(fn);
// TODO: truncate to 32 chars? // TODO: truncate to 32 chars?
Bfree(map->name); Xfree(map->name);
map->name = Xstrdup(levelname); map->name = Xstrdup(levelname);
map->partime = REALGAMETICSPERSEC * partime; map->partime = REALGAMETICSPERSEC * partime;
@ -2549,7 +2549,7 @@ DO_DEFSTATE:
C_ReportError(-1); C_ReportError(-1);
initprintf("%s:%d: warning: expected state, found %s.\n", g_scriptFileName, g_lineNumber, gl); initprintf("%s:%d: warning: expected state, found %s.\n", g_scriptFileName, g_lineNumber, gl);
g_warningCnt++; g_warningCnt++;
Bfree(gl); Xfree(gl);
scriptWriteAtOffset(CON_NULLOP, &g_scriptPtr[-1]); // get rid of the state, leaving a nullop to satisfy if conditions scriptWriteAtOffset(CON_NULLOP, &g_scriptPtr[-1]); // get rid of the state, leaving a nullop to satisfy if conditions
continue; // valid label name, but wrong type continue; // valid label name, but wrong type
} }
@ -6232,7 +6232,7 @@ void C_Compile(const char *fileName)
g_scriptcrc = Bcrc32(NULL, 0, 0L); g_scriptcrc = Bcrc32(NULL, 0, 0L);
g_scriptcrc = Bcrc32(textptr, kFileLen, g_scriptcrc); g_scriptcrc = Bcrc32(textptr, kFileLen, g_scriptcrc);
Bfree(apScript); Xfree(apScript);
apScript = (intptr_t *)Xcalloc(1, g_scriptSize * sizeof(intptr_t)); apScript = (intptr_t *)Xcalloc(1, g_scriptSize * sizeof(intptr_t));
bitptr = (uint8_t *)Xcalloc(1, (((g_scriptSize + 7) >> 3) + 1) * sizeof(uint8_t)); bitptr = (uint8_t *)Xcalloc(1, (((g_scriptSize + 7) >> 3) + 1) * sizeof(uint8_t));

View file

@ -5544,7 +5544,7 @@ badindex:
if (newBytes != oldBytes) if (newBytes != oldBytes)
{ {
Baligned_free(pValues); Xaligned_free(pValues);
pValues = (intptr_t *)Xaligned_alloc(ARRAY_ALIGNMENT, newBytes); pValues = (intptr_t *)Xaligned_alloc(ARRAY_ALIGNMENT, newBytes);
} }
@ -5572,7 +5572,7 @@ badindex:
pValues[i] = ((int32_t *)pArray)[i]; pValues[i] = ((int32_t *)pArray)[i];
} }
Bfree(pArray); Xfree(pArray);
break; break;
} }
#endif #endif
@ -5624,7 +5624,7 @@ badindex:
pArray[k] = Gv_GetArrayValue(arrayNum, k); pArray[k] = Gv_GetArrayValue(arrayNum, k);
buildvfs_fwrite(pArray, 1, numDiskBytes, fil); buildvfs_fwrite(pArray, 1, numDiskBytes, fil);
Bfree(pArray); Xfree(pArray);
break; break;
} }
#endif #endif
@ -5659,7 +5659,7 @@ badindex:
#endif #endif
if (newSize == 0) if (newSize == 0)
{ {
Baligned_free(arr.pValues); Xaligned_free(arr.pValues);
arr.pValues = nullptr; arr.pValues = nullptr;
arr.size = 0; arr.size = 0;
dispatch(); dispatch();
@ -5680,7 +5680,7 @@ badindex:
arr.pValues = newArray; arr.pValues = newArray;
arr.size = newSize; arr.size = newSize;
Baligned_free(oldArray); Xaligned_free(oldArray);
dispatch(); dispatch();
} }
@ -6496,7 +6496,7 @@ void G_SaveMapState(void)
continue; continue;
save->arraysiz[i] = aGameArrays[i].size; save->arraysiz[i] = aGameArrays[i].size;
Baligned_free(save->arrays[i]); Xaligned_free(save->arrays[i]);
save->arrays[i] = (intptr_t *)Xaligned_alloc(ARRAY_ALIGNMENT, Gv_GetArrayAllocSize(i)); save->arrays[i] = (intptr_t *)Xaligned_alloc(ARRAY_ALIGNMENT, Gv_GetArrayAllocSize(i));
Bmemcpy(&save->arrays[i][0], aGameArrays[i].pValues, Gv_GetArrayAllocSize(i)); Bmemcpy(&save->arrays[i][0], aGameArrays[i].pValues, Gv_GetArrayAllocSize(i));
} }
@ -6511,7 +6511,7 @@ void G_SaveMapState(void)
else else
{ {
char *savecode = Xstrdup(svcode); char *savecode = Xstrdup(svcode);
Bfree(save->savecode); Xfree(save->savecode);
save->savecode = savecode; save->savecode = savecode;
} }
#endif #endif
@ -6629,7 +6629,7 @@ void G_RestoreMapState(void)
continue; continue;
aGameArrays[i].size = pSavedState->arraysiz[i]; aGameArrays[i].size = pSavedState->arraysiz[i];
Baligned_free(aGameArrays[i].pValues); Xaligned_free(aGameArrays[i].pValues);
aGameArrays[i].pValues = (intptr_t *) Xaligned_alloc(ARRAY_ALIGNMENT, Gv_GetArrayAllocSize(i)); aGameArrays[i].pValues = (intptr_t *) Xaligned_alloc(ARRAY_ALIGNMENT, Gv_GetArrayAllocSize(i));
Bmemcpy(aGameArrays[i].pValues, pSavedState->arrays[i], Gv_GetArrayAllocSize(i)); Bmemcpy(aGameArrays[i].pValues, pSavedState->arrays[i], Gv_GetArrayAllocSize(i));

View file

@ -251,13 +251,13 @@ static void FreeGameList(void)
{ {
while (listgrps) while (listgrps)
{ {
Bfree(listgrps->name); Xfree(listgrps->name);
Bfree(listgrps->scriptname); Xfree(listgrps->scriptname);
Bfree(listgrps->defname); Xfree(listgrps->defname);
Bfree(listgrps->rtsname); Xfree(listgrps->rtsname);
grpinfo_t * const fg = listgrps->next; grpinfo_t * const fg = listgrps->next;
Bfree(listgrps); Xfree(listgrps);
listgrps = fg; listgrps = fg;
} }
} }
@ -312,7 +312,7 @@ static void FreeGroupsCache(void)
while (grpcache) while (grpcache)
{ {
struct grpcache * const fg = grpcache->next; struct grpcache * const fg = grpcache->next;
Bfree(grpcache); Xfree(grpcache);
grpcache = fg; grpcache = fg;
} }
} }
@ -328,8 +328,8 @@ static void RemoveGroup(grpfile_t *igrp)
else else
prev->next = grp->next; prev->next = grp->next;
Bfree((char *)grp->filename); Xfree((char *)grp->filename);
Bfree(grp); Xfree(grp);
return; return;
} }
@ -388,10 +388,10 @@ static void ProcessGroups(CACHE1D_FIND_REC *srch)
if (findfrompath(sidx->name, &fn)) continue; // failed to resolve the filename if (findfrompath(sidx->name, &fn)) continue; // failed to resolve the filename
if (Bstat(fn, &st)) if (Bstat(fn, &st))
{ {
Bfree(fn); Xfree(fn);
continue; continue;
} // failed to stat the file } // failed to stat the file
Bfree(fn); Xfree(fn);
if (fg->size == (int32_t)st.st_size && fg->mtime == (int32_t)st.st_mtime) if (fg->size == (int32_t)st.st_size && fg->mtime == (int32_t)st.st_mtime)
{ {
grpinfo_t const * const grptype = FindGrpInfo(fg->crcval, fg->size); grpinfo_t const * const grptype = FindGrpInfo(fg->crcval, fg->size);
@ -453,7 +453,7 @@ static void ProcessGroups(CACHE1D_FIND_REC *srch)
} }
} }
Bfree(buf); Xfree(buf);
} }
#endif #endif
@ -508,7 +508,7 @@ int32_t ScanGroups(void)
{ {
fgg = fg->next; fgg = fg->next;
fprintf(fp, "\"%s\" %d %d %d\n", fg->name, fg->size, fg->mtime, fg->crcval); fprintf(fp, "\"%s\" %d %d %d\n", fg->name, fg->size, fg->mtime, fg->crcval);
Bfree(fg); Xfree(fg);
i++; i++;
} }
buildvfs_fclose(fp); buildvfs_fclose(fp);
@ -529,9 +529,9 @@ void FreeGroups(void)
{ {
while (foundgrps) while (foundgrps)
{ {
Bfree((char *)foundgrps->filename); Xfree((char *)foundgrps->filename);
grpfile_t * const fg = foundgrps->next; grpfile_t * const fg = foundgrps->next;
Bfree(foundgrps); Xfree(foundgrps);
foundgrps = fg; foundgrps = fg;
} }

View file

@ -219,7 +219,7 @@ nextline:
} }
// ---- // ----
Bfree(filebuf); Xfree(filebuf);
return 0; return 0;
} }
@ -399,11 +399,11 @@ static void free_self_and_successors(mapundo_t *mapst)
{ {
(*refcnt)--; (*refcnt)--;
if (*refcnt == 0) if (*refcnt == 0)
Bfree(refcnt); // free the block! Xfree(refcnt); // free the block!
} }
} }
Bfree(cur); Xfree(cur);
if (!prev) if (!prev)
break; break;
@ -492,7 +492,7 @@ void create_map_snapshot(void)
} }
create_compressed_block(2, tspri, Numsprites*sizeof(spritetype), temphash); create_compressed_block(2, tspri, Numsprites*sizeof(spritetype), temphash);
Bfree(tspri); Xfree(tspri);
} }
} }
#undef XXH__ #undef XXH__
@ -1411,8 +1411,8 @@ too_many_errors:
if (seen_nextwalls) if (seen_nextwalls)
{ {
Bfree(seen_nextwalls); Xfree(seen_nextwalls);
Bfree(lastnextwallsource); Xfree(lastnextwallsource);
} }
corruptlevel = errlevel; corruptlevel = errlevel;
@ -1741,7 +1741,7 @@ static void FuncMenu_Process(const StatusBarMenu *m, int32_t col, int32_t row)
tmpscript[1+5+1+snlen] = 0; tmpscript[1+5+1+snlen] = 0;
M32RunScript(tmpscript); M32RunScript(tmpscript);
Bfree(tmpscript); Xfree(tmpscript);
if (vm.flags&VMFLAG_ERROR) if (vm.flags&VMFLAG_ERROR)
printmessage16("There were errors while executing the menu function"); printmessage16("There were errors while executing the menu function");

View file

@ -1470,7 +1470,7 @@ static int32_t C_GetNextValue(int32_t type)
// { // {
// gl = (char *)C_GetLabelType(labeltype[i]); // gl = (char *)C_GetLabelType(labeltype[i]);
// initprintf("%s:%d: debug: accepted %s label `%s'.\n",g_szScriptFileName,g_lineNumber,gl,label+(i*MAXLABELLEN)); // initprintf("%s:%d: debug: accepted %s label `%s'.\n",g_szScriptFileName,g_lineNumber,gl,label+(i*MAXLABELLEN));
// Bfree(gl); // Xfree(gl);
// } // }
*(g_scriptPtr++) = thesign*labelval[i]; *(g_scriptPtr++) = thesign*labelval[i];
@ -1486,8 +1486,8 @@ static int32_t C_GetNextValue(int32_t type)
gl = C_GetLabelType(labeltype[i]); gl = C_GetLabelType(labeltype[i]);
C_CUSTOMERROR("expected %s, found %s.", el, gl); C_CUSTOMERROR("expected %s, found %s.", el, gl);
// initprintf("i=%d, %s!!! lt:%d t:%d\n", i, label+(i*MAXLABELLEN), labeltype[i], type); // initprintf("i=%d, %s!!! lt:%d t:%d\n", i, label+(i*MAXLABELLEN), labeltype[i], type);
Bfree(el); Xfree(el);
Bfree(gl); Xfree(gl);
return -1; // valid label name, but wrong type return -1; // valid label name, but wrong type
} }
@ -1779,7 +1779,7 @@ static int32_t C_ParseCommand(void)
textptr = origtptr; textptr = origtptr;
Bfree(mptr); Xfree(mptr);
} }
return 0; return 0;
@ -3721,7 +3721,7 @@ void C_Compile(const char *filenameortext, int32_t isfilename)
if (fp == buildvfs_kfd_invalid) if (fp == buildvfs_kfd_invalid)
{ {
initprintf("M32 file `%s' not found.\n", mptr); initprintf("M32 file `%s' not found.\n", mptr);
Bfree(mptr); Xfree(mptr);
//g_loadFromGroupOnly = 1; //g_loadFromGroupOnly = 1;
return; return;
} }
@ -3731,7 +3731,7 @@ void C_Compile(const char *filenameortext, int32_t isfilename)
initprintf(" \n"); initprintf(" \n");
initprintf("--- Compiling: %s (%d bytes)\n",mptr,fs); initprintf("--- Compiling: %s (%d bytes)\n",mptr,fs);
Bstrcpy(g_szScriptFileName, mptr); // JBF 20031130: Store currently compiling file name Bstrcpy(g_szScriptFileName, mptr); // JBF 20031130: Store currently compiling file name
Bfree(mptr); Xfree(mptr);
} }
else else
{ {
@ -3779,7 +3779,7 @@ void C_Compile(const char *filenameortext, int32_t isfilename)
//*script = g_scriptPtr-script; //*script = g_scriptPtr-script;
Bfree(mptr); Xfree(mptr);
if (g_stateCount > ostateCount) if (g_stateCount > ostateCount)
{ {
@ -4011,6 +4011,6 @@ void C_PrintErrorPosition()
initprintf("%s\n", buf); initprintf("%s\n", buf);
Bfree(buf); Xfree(buf);
} }
} }

View file

@ -4778,7 +4778,7 @@ void Net_Connect(const char *srvaddr)
if (enet_host_service(g_netClient, &event, 5000) > 0 && event.type == ENET_EVENT_TYPE_CONNECT) if (enet_host_service(g_netClient, &event, 5000) > 0 && event.type == ENET_EVENT_TYPE_CONNECT)
{ {
initprintf("Connection to %s:%d succeeded.\n", oursrvaddr, address.port); initprintf("Connection to %s:%d succeeded.\n", oursrvaddr, address.port);
Bfree(oursrvaddr); Xfree(oursrvaddr);
return; return;
} }
else else
@ -4793,7 +4793,7 @@ void Net_Connect(const char *srvaddr)
} }
// [75] note: it only gets here if there was an error // [75] note: it only gets here if there was an error
Bfree(oursrvaddr); Xfree(oursrvaddr);
Net_Disconnect(); Net_Disconnect();
} }

View file

@ -2067,7 +2067,7 @@ void G_FreeMapState(int levelNum)
ALIGNED_FREE_AND_NULL(board.savedstate->arrays[j]); ALIGNED_FREE_AND_NULL(board.savedstate->arrays[j]);
} }
#else #else
Bfree(board.savedstate->savecode); Xfree(board.savedstate->savecode);
#endif #endif
ALIGNED_FREE_AND_NULL(board.savedstate); ALIGNED_FREE_AND_NULL(board.savedstate);

View file

@ -96,7 +96,7 @@ static int32_t RTS_AddFile(const char *filename)
Bstrncpy(lump->name, fileinfo->name, 8); Bstrncpy(lump->name, fileinfo->name, 8);
} }
Bfree(fileinfoo); Xfree(fileinfoo);
return 0; return 0;
} }

View file

@ -1909,7 +1909,7 @@ static void sv_quoteredefload()
} }
static void sv_postquoteredef() static void sv_postquoteredef()
{ {
Bfree(savegame_quoteredefs), savegame_quoteredefs=NULL; Xfree(savegame_quoteredefs), savegame_quoteredefs=NULL;
} }
static void sv_restsave() static void sv_restsave()
{ {
@ -2055,7 +2055,7 @@ static int32_t El_ReadSaveCode(buildvfs_kfd fil)
if (kdfread_LZ4(svcode, 1, slen, fil) != slen) // cnt and sz swapped if (kdfread_LZ4(svcode, 1, slen, fil) != slen) // cnt and sz swapped
{ {
OSD_Printf("doloadplayer2: failed reading Lunatic gamevar restoration code.\n"); OSD_Printf("doloadplayer2: failed reading Lunatic gamevar restoration code.\n");
Bfree(svcode); Xfree(svcode);
return -104; return -104;
} }
@ -2069,7 +2069,7 @@ static int32_t El_ReadSaveCode(buildvfs_kfd fil)
void El_FreeSaveCode(void) void El_FreeSaveCode(void)
{ {
// Free Lunatic gamevar savegame restoration Lua code. // Free Lunatic gamevar savegame restoration Lua code.
Bfree(g_elSavecode); Xfree(g_elSavecode);
g_elSavecode = NULL; g_elSavecode = NULL;
} }
#endif #endif

View file

@ -55,7 +55,7 @@ int32_t G_GetStringNumLines(const char *text, const char *end, const int32_t ite
} }
// Note: Neither of these care about TEXT_LINEWRAP. This is intended. // Note: Neither of these care about TEXT_LINEWRAP. This is intended.
// This function requires you to Bfree() the returned char*. // This function requires you to Xfree() the returned char*.
char* G_GetSubString(const char *text, const char *end, const int32_t iter, const int32_t length) char* G_GetSubString(const char *text, const char *end, const int32_t iter, const int32_t length)
{ {
char *line = (char*) Xmalloc((length+1) * sizeof(char)); char *line = (char*) Xmalloc((length+1) * sizeof(char));
@ -536,7 +536,7 @@ vec2_t G_ScreenText(const int32_t font,
linewidth = G_ScreenTextSize(font, x, y, z, blockangle, line, o | ROTATESPRITE_FULL16, xspace_orig, yline_orig, (f & TEXT_XJUSTIFY) ? 0 : xbetween_orig, (f & TEXT_YJUSTIFY) ? 0 : ybetween_orig, f & ~(TEXT_XJUSTIFY|TEXT_YJUSTIFY|TEXT_BACKWARDS), x1, y1, x2, y2).x; linewidth = G_ScreenTextSize(font, x, y, z, blockangle, line, o | ROTATESPRITE_FULL16, xspace_orig, yline_orig, (f & TEXT_XJUSTIFY) ? 0 : xbetween_orig, (f & TEXT_YJUSTIFY) ? 0 : ybetween_orig, f & ~(TEXT_XJUSTIFY|TEXT_YJUSTIFY|TEXT_BACKWARDS), x1, y1, x2, y2).x;
Bfree(line); Xfree(line);
} }
if (f & TEXT_XJUSTIFY) if (f & TEXT_XJUSTIFY)
@ -728,7 +728,7 @@ vec2_t G_ScreenText(const int32_t font,
int32_t linewidth = G_ScreenTextSize(font, x, y, z, blockangle, line, o | ROTATESPRITE_FULL16, xspace_orig, yline_orig, (f & TEXT_XJUSTIFY) ? 0 : xbetween_orig, (f & TEXT_YJUSTIFY) ? 0 : ybetween_orig, f & ~(TEXT_XJUSTIFY|TEXT_YJUSTIFY|TEXT_BACKWARDS), x1, y1, x2, y2).x; int32_t linewidth = G_ScreenTextSize(font, x, y, z, blockangle, line, o | ROTATESPRITE_FULL16, xspace_orig, yline_orig, (f & TEXT_XJUSTIFY) ? 0 : xbetween_orig, (f & TEXT_YJUSTIFY) ? 0 : ybetween_orig, f & ~(TEXT_XJUSTIFY|TEXT_YJUSTIFY|TEXT_BACKWARDS), x1, y1, x2, y2).x;
Bfree(line); Xfree(line);
if (f & TEXT_XJUSTIFY) if (f & TEXT_XJUSTIFY)
{ {

View file

@ -75,7 +75,7 @@ bool CONTROL_BindsEnabled = 0;
bool CONTROL_SmoothMouse = 0; bool CONTROL_SmoothMouse = 0;
#define CONTROL_CheckRange(which) ((unsigned)which >= (unsigned)CONTROL_NUM_FLAGS) #define CONTROL_CheckRange(which) ((unsigned)which >= (unsigned)CONTROL_NUM_FLAGS)
#define BIND(x, s, r, k) do { Bfree(x.cmdstr); x.cmdstr = s; x.repeat = r; x.key = k; } while (0) #define BIND(x, s, r, k) do { Xfree(x.cmdstr); x.cmdstr = s; x.repeat = r; x.key = k; } while (0)
void CONTROL_ClearAllBinds(void) void CONTROL_ClearAllBinds(void)
{ {

View file

@ -77,15 +77,15 @@ void SCRIPT_Delete(int32_t scripthandle)
{ {
s = SCRIPT(scripthandle,apScript)->nextsection; s = SCRIPT(scripthandle,apScript)->nextsection;
SCRIPT_FreeSection(SCRIPT(scripthandle,apScript)); SCRIPT_FreeSection(SCRIPT(scripthandle,apScript));
Bfree(SCRIPT(scripthandle,apScript)); Xfree(SCRIPT(scripthandle,apScript));
SCRIPT(scripthandle,apScript) = s; SCRIPT(scripthandle,apScript) = s;
} }
SCRIPT_FreeSection(SCRIPT(scripthandle, apScript)); SCRIPT_FreeSection(SCRIPT(scripthandle, apScript));
Bfree(SCRIPT(scripthandle,apScript)); Xfree(SCRIPT(scripthandle,apScript));
} }
Bfree(SC(scripthandle)); Xfree(SC(scripthandle));
SC(scripthandle) = 0; SC(scripthandle) = 0;
} }
@ -100,16 +100,16 @@ void SCRIPT_FreeSection(ScriptSectionType * section)
{ {
e = section->entries->nextentry; e = section->entries->nextentry;
Bfree(section->entries->name); Xfree(section->entries->name);
Bfree(section->entries->value); Xfree(section->entries->value);
Bfree(section->entries); Xfree(section->entries);
section->entries = e; section->entries = e;
} }
Bfree(section->entries->name); Xfree(section->entries->name);
Bfree(section->entries->value); Xfree(section->entries->value);
Bfree(section->entries); Xfree(section->entries);
Bfree(section->name); Xfree(section->name);
} }
#define AllocSection(s) \ #define AllocSection(s) \
@ -220,7 +220,7 @@ void SCRIPT_AddEntry(int32_t scripthandle, const char * sectionname, const char
} }
} }
Bfree(e->value); Xfree(e->value);
e->value = Xstrdup(entryvalue); e->value = Xstrdup(entryvalue);
} }
@ -460,13 +460,13 @@ int32_t SCRIPT_Load(char const * filename)
s = SCRIPT_Init(filename); s = SCRIPT_Init(filename);
if (s<0) if (s<0)
{ {
Bfree(b); Xfree(b);
return -1; return -1;
} }
SCRIPT_ParseBuffer(s,b,l); SCRIPT_ParseBuffer(s,b,l);
Bfree(b); Xfree(b);
return s; return s;
} }
@ -811,7 +811,7 @@ void SCRIPT_PutString(int32_t scripthandle, char const *sectionname, char const
*p=0; *p=0;
SCRIPT_AddEntry(scripthandle, sectionname, entryname, raw); SCRIPT_AddEntry(scripthandle, sectionname, entryname, raw);
Bfree(raw); Xfree(raw);
} }
void SCRIPT_PutDoubleString void SCRIPT_PutDoubleString
@ -864,7 +864,7 @@ void SCRIPT_PutDoubleString
*p=0; *p=0;
SCRIPT_AddEntry(scripthandle, sectionname, entryname, raw); SCRIPT_AddEntry(scripthandle, sectionname, entryname, raw);
Bfree(raw); Xfree(raw);
} }
void SCRIPT_PutNumber void SCRIPT_PutNumber