summaryrefslogtreecommitdiffhomepage
path: root/src/external/jar_mod.h
diff options
context:
space:
mode:
authorraysan5 <[email protected]>2020-01-19 11:42:16 +0100
committerraysan5 <[email protected]>2020-01-19 11:42:16 +0100
commitd797bb3e1cef4541eadc09ebe9c67f2b229613dd (patch)
treeac5043011363bb9500f2a46b64152151a4b61026 /src/external/jar_mod.h
parentbec467705e83ecf66f4bf75ddbcad8ac4a9d8e95 (diff)
downloadraylib-d797bb3e1cef4541eadc09ebe9c67f2b229613dd.tar.gz
raylib-d797bb3e1cef4541eadc09ebe9c67f2b229613dd.zip
Support custom memory allocators
Diffstat (limited to 'src/external/jar_mod.h')
-rw-r--r--src/external/jar_mod.h30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/external/jar_mod.h b/src/external/jar_mod.h
index c17130a6..eacd3b7d 100644
--- a/src/external/jar_mod.h
+++ b/src/external/jar_mod.h
@@ -81,15 +81,13 @@
#ifndef INCLUDE_JAR_MOD_H
#define INCLUDE_JAR_MOD_H
-#include <stdio.h>
-#include <stdlib.h>
-//#include <stdbool.h>
-
-
-#ifdef __cplusplus
-extern "C" {
+// Allow custom memory allocators
+#ifndef JARMOD_MALLOC
+ #define JARMOD_MALLOC(sz) malloc(sz)
+#endif
+#ifndef JARMOD_FREE
+ #define JARMOD_FREE(p) free(p)
#endif
-
// Basic type
@@ -240,7 +238,9 @@ typedef struct jar_mod_tracker_buffer_state_
tracker_state * track_state_buf;
}jar_mod_tracker_buffer_state;
-
+#ifdef __cplusplus
+extern "C" {
+#endif
bool jar_mod_init(jar_mod_context_t * modctx);
bool jar_mod_setcfg(jar_mod_context_t * modctx, int samplerate, int bits, int stereo, int stereo_separation, int filter);
@@ -261,6 +261,10 @@ void jar_mod_seek_start(jar_mod_context_t * ctx);
//-------------------------------------------------------------------------------
#ifdef JAR_MOD_IMPLEMENTATION
+#include <stdio.h>
+#include <stdlib.h>
+//#include <stdbool.h>
+
// Effects list
#define EFFECT_ARPEGGIO 0x0 // Supported
#define EFFECT_PORTAMENTO_UP 0x1 // Supported
@@ -1504,7 +1508,7 @@ void jar_mod_unload( jar_mod_context_t * modctx)
{
if(modctx->modfile)
{
- free(modctx->modfile);
+ JARMOD_FREE(modctx->modfile);
modctx->modfile = 0;
modctx->modfilesize = 0;
modctx->loopcount = 0;
@@ -1513,14 +1517,12 @@ void jar_mod_unload( jar_mod_context_t * modctx)
}
}
-
-
mulong jar_mod_load_file(jar_mod_context_t * modctx, const char* filename)
{
mulong fsize = 0;
if(modctx->modfile)
{
- free(modctx->modfile);
+ JARMOD_FREE(modctx->modfile);
modctx->modfile = 0;
}
@@ -1533,7 +1535,7 @@ mulong jar_mod_load_file(jar_mod_context_t * modctx, const char* filename)
if(fsize && fsize < 32*1024*1024)
{
- modctx->modfile = malloc(fsize);
+ modctx->modfile = JARMOD_MALLOC(fsize);
modctx->modfilesize = fsize;
memset(modctx->modfile, 0, fsize);
fread(modctx->modfile, fsize, 1, f);