Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Richard Gobeille
EDuke32
Commits
deb8f0f6
Commit
deb8f0f6
authored
Aug 08, 2020
by
Richard Gobeille
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
engine/all: allocation fixes WIP
parent
b91898fc
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
149 additions
and
118 deletions
+149
-118
source/audiolib/src/multivoc.cpp
source/audiolib/src/multivoc.cpp
+1
-1
source/audiolib/src/stb_vorbis.c
source/audiolib/src/stb_vorbis.c
+10
-10
source/build/include/collections.h
source/build/include/collections.h
+1
-1
source/build/include/compat.h
source/build/include/compat.h
+67
-23
source/build/include/miniz_common.h
source/build/include/miniz_common.h
+3
-3
source/build/include/sjson.h
source/build/include/sjson.h
+3
-3
source/build/src/build.cpp
source/build/src/build.cpp
+2
-2
source/build/src/compat.cpp
source/build/src/compat.cpp
+22
-31
source/build/src/lz4.c
source/build/src/lz4.c
+3
-3
source/build/src/polymost.cpp
source/build/src/polymost.cpp
+4
-4
source/build/src/poolallocator.cpp
source/build/src/poolallocator.cpp
+2
-2
source/build/src/smmalloc_generic.cpp
source/build/src/smmalloc_generic.cpp
+21
-25
source/build/src/tiles.cpp
source/build/src/tiles.cpp
+2
-2
source/build/src/xxhash.c
source/build/src/xxhash.c
+2
-2
source/duke3d/src/astub.cpp
source/duke3d/src/astub.cpp
+1
-1
source/duke3d/src/cmdline.cpp
source/duke3d/src/cmdline.cpp
+2
-2
source/duke3d/src/game.cpp
source/duke3d/src/game.cpp
+2
-2
source/duke3d/src/gamedef.cpp
source/duke3d/src/gamedef.cpp
+1
-1
No files found.
source/audiolib/src/multivoc.cpp
View file @
deb8f0f6
...
...
@@ -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
**
)
B
calloc
(
Voices
,
sizeof
(
intptr_t
));
MV_Handles
=
(
VoiceNode
**
)
X
calloc
(
Voices
,
sizeof
(
intptr_t
));
#ifdef ASS_REVERSESTEREO
MV_SetReverseStereo
(
FALSE
);
#endif
...
...
source/audiolib/src/stb_vorbis.c
View file @
deb8f0f6
...
...
@@ -942,13 +942,13 @@ static void *setup_malloc(vorb *f, int sz)
f
->
setup_offset
+=
sz
;
return
p
;
}
return
sz
?
B
malloc
(
sz
)
:
NULL
;
return
sz
?
X
malloc
(
sz
)
:
NULL
;
}
static
void
setup_free
(
vorb
*
f
,
void
*
p
)
{
if
(
f
->
alloc
.
alloc_buffer
)
return
;
// do nothing; setup mem is a stack
B
free
(
p
);
X
free
(
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
B
malloc
(
sz
);
return
X
malloc
(
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
;
}
B
free
(
p
);
X
free
(
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
*
)
B
malloc
(
total
*
sizeof
(
*
data
));
data
=
(
short
*
)
X
malloc
(
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
*
)
B
realloc
(
data
,
total
*
sizeof
(
*
data
));
data2
=
(
short
*
)
X
realloc
(
data
,
total
*
sizeof
(
*
data
));
if
(
data2
==
NULL
)
{
B
free
(
data
);
X
free
(
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
*
)
B
malloc
(
total
*
sizeof
(
*
data
));
data
=
(
short
*
)
X
malloc
(
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
*
)
B
realloc
(
data
,
total
*
sizeof
(
*
data
));
data2
=
(
short
*
)
X
realloc
(
data
,
total
*
sizeof
(
*
data
));
if
(
data2
==
NULL
)
{
B
free
(
data
);
X
free
(
data
);
stb_vorbis_close
(
v
);
return
-
2
;
}
...
...
source/build/include/collections.h
View file @
deb8f0f6
...
...
@@ -50,7 +50,7 @@ struct GrowArray
{
size_
=
0
;
capacity_
=
0
;
B
free
(
data_
);
X
free
(
data_
);
data_
=
nullptr
;
}
...
...
source/build/include/compat.h
View file @
deb8f0f6
...
...
@@ -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 { \
B
free(var); (var) =
NULL
; \
X
free(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
*
)
B
realloc
(
*
buffer
,
newsize
);
*
buffer
=
(
char
*
)
X
realloc
(
*
buffer
,
newsize
);
*
buffersize
=
newsize
;
}
}
...
...
source/build/include/miniz_common.h
View file @
deb8f0f6
...
...
@@ -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)
B
malloc(x)
#define MZ_FREE(x)
B
free(x)
#define MZ_REALLOC(p, x)
B
realloc(p, x)
#define MZ_MALLOC(x)
X
malloc(x)
#define MZ_FREE(x)
X
free(x)
#define MZ_REALLOC(p, x)
X
realloc(p, x)
#endif
#define MZ_MAX(a, b) (((a) > (b)) ? (a) : (b))
...
...
source/build/include/sjson.h
View file @
deb8f0f6
...
...
@@ -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)),
B
malloc(size))
# define sjson_free(user, ptr) ((UNREFERENCED_PARAMETER(user)),
B
free(ptr))
# define sjson_realloc(user, ptr, size) ((UNREFERENCED_PARAMETER(user)),
B
realloc(ptr, size))
# define sjson_malloc(user, size) ((UNREFERENCED_PARAMETER(user)),
X
malloc(size))
# define sjson_free(user, ptr) ((UNREFERENCED_PARAMETER(user)),
X
free(ptr))
# define sjson_realloc(user, ptr, size) ((UNREFERENCED_PARAMETER(user)),
X
realloc(ptr, size))
#endif
#ifndef sjson_assert
...
...
source/build/src/build.cpp
View file @
deb8f0f6
...
...
@@ -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
)
B
free
(
m
);
X
free
(
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
)
B
free
(
f
);
X
free
(
f
);
g_clipMapFiles
.
clear
();
#endif
...
...
source/build/src/compat.cpp
View file @
deb8f0f6
...
...
@@ -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_memer
r
);
EDUKE32_UNREACHABLE_SECTION
(
return
nullpt
r
);
}
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
)
{
B
free
(
ptr
);
}
void
Cxfree
(
void
*
const
ptr
)
{
X
free
(
ptr
);
}
}
//
...
...
@@ -110,7 +101,7 @@ char *Bgethomedir(void)
{
if
(
loaded
)
FreeLibrary
(
hShell32
);
return
B
strdup
(
appdata
);
return
X
strdup
(
appdata
);
}
}
...
...
@@ -126,11 +117,11 @@ char *Bgethomedir(void)
drv
=
strchr
(
cwd
,
':'
);
if
(
drv
)
drv
[
1
]
=
'\0'
;
return
B
strdup
(
cwd
);
return
X
strdup
(
cwd
);
#else
char
*
e
=
getenv
(
"HOME"
);
if
(
!
e
)
return
NULL
;
return
B
strdup
(
e
);
return
X
strdup
(
e
);
#endif
}
...
...
@@ -145,7 +136,7 @@ char *Bgetappdir(void)
// trim off the filename
char
*
slash
=
Bstrrchr
(
appdir
,
'\\'
);
if
(
slash
)
slash
[
0
]
=
0
;
dir
=
B
strdup
(
appdir
);
dir
=
X
strdup
(
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
=
B
strdup
(
dirname
(
buf
));
dir
=
X
strdup
(
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
=
B
strdup
(
dirname
(
buf2
));
dir
=
X
strdup
(
dirname
(
buf2
));
}
#endif
...
...
@@ -186,7 +177,7 @@ char *Bgetappdir(void)
int32_t
Bcorrectfilename
(
char
*
filename
,
int32_t
removefn
)
{
char
*
fn
=
B
strdup
(
filename
);
char
*
fn
=
X
strdup
(
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
;
B
free
(
fn
);
X
free
(
fn
);
return
0
;
}
...
...
@@ -315,7 +306,7 @@ char *Bgetsystemdrives(void)
number
++
;
}
str
=
p
=
(
char
*
)
B
malloc
(
1
+
(
3
*
number
));
str
=
p
=
(
char
*
)
X
malloc
(
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
*
)
B
malloc
(
Bstrlen
(
name
)
+
1
+
4
);
t
=
(
char
*
)
X
malloc
(
Bstrlen
(
name
)
+
1
+
4
);
#endif
dirr
=
(
BDIR_real
*
)
B
malloc
(
sizeof
(
BDIR_real
)
+
Bstrlen
(
name
));
dirr
=
(
BDIR_real
*
)
X
malloc
(
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
);
B
free
(
t
);
X
free
(
t
);
if
(
dirr
->
dir
==
-
1
)
{
B
free
(
dirr
);
X
free
(
dirr
);
return
NULL
;
}
#else
dirr
->
dir
=
opendir
(
name
);
if
(
dirr
->
dir
==
NULL
)
{
B
free
(
dirr
);
X
free
(
dirr
);
return
NULL
;
}
#endif
...
...
@@ -426,7 +417,7 @@ struct Bdirent *Breaddir(BDIR *dir)
dirr
->
info
.
size
=
0
;
dirr
->
info
.
mtime
=
0
;
char
*
fn
=
(
char
*
)
B
malloc
(
Bstrlen
(
dirr
->
name
)
+
1
+
dirr
->
info
.
namlen
+
1
);
char
*
fn
=
(
char
*
)
X
malloc
(
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
B
free
(
fn
);
X
free
(
fn
);
return
&
dirr
->
info
;
}
...
...
@@ -461,7 +452,7 @@ int32_t Bclosedir(BDIR *dir)
#else
closedir
(
dirr
->
dir
);
#endif
B
free
(
dirr
);
X
free
(
dirr
);
return
0
;
}
...
...
source/build/src/lz4.c
View file @
deb8f0f6
...
...
@@ -176,9 +176,9 @@
* Memory routines
**************************************/
#include "compat.h"
#define ALLOC(s)
B
malloc(s)
#define ALLOC_AND_ZERO(s)
B
calloc(1,s)
#define FREEMEM(p)
B
free(p)
#define ALLOC(s)
X
malloc(s)
#define ALLOC_AND_ZERO(s)
X
calloc(1,s)
#define FREEMEM(p)
X
free(p)
#include <string.h>
/* memset, memcpy */
#define MEM_INIT(p,v,s) memset((p),(v),(s))
...
...
source/build/src/polymost.cpp
View file @
deb8f0f6
...
...
@@ -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
*
)
B
malloc
(
logLength
);
char
*
infoLog
=
(
char
*
)
X
malloc
(
logLength
);
glGetShaderInfoLog
(
shaderID
,
logLength
,
&
logLength
,
infoLog
);
OSD_Printf
(
"Log:
\n
%s
\n
"
,
infoLog
);
B
free
(
infoLog
);
X
free
(
infoLog
);
}
}
...
...
@@ -1134,7 +1134,7 @@ void polymost_glinit()
glLinkProgram
(
polymost1ExtendedShaderProgramID
);
int
polymost1BasicFragLen
=
strlen
(
polymost1Frag
);
char
*
polymost1BasicFrag
=
(
char
*
)
B
malloc
(
polymost1BasicFragLen
);
char
*
polymost1BasicFrag
=
(
char
*
)
X
malloc
(
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
);
B
free
(
polymost1BasicFrag
);
X
free
(
polymost1BasicFrag
);
polymost1BasicFrag
=
0
;
// set defaults
...
...
source/build/src/poolallocator.cpp
View file @
deb8f0f6
...
...
@@ -35,11 +35,11 @@ PoolAllocator::PoolAllocator(size_t const totalSize, size_t const chunkSize) : A
void
PoolAllocator
::
Init
()
{
m_start_ptr
=
B
malloc
(
m_totalSize
);
m_start_ptr
=
X
malloc
(
m_totalSize
);
this
->
Reset
();
}
PoolAllocator
::~
PoolAllocator
()
{
B
free
(
m_start_ptr
);
}
PoolAllocator
::~
PoolAllocator
()
{
X
free
(
m_start_ptr
);
}
void
*
PoolAllocator
::
Allocate
(
size_t
const
allocationSize
,
size_t
const
)
{
...
...
source/build/src/smmalloc_generic.cpp
View file @
deb8f0f6
...
...
@@ -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
);
B
aligned_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
*
);