summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRay <[email protected]>2021-03-08 18:48:27 +0100
committerRay <[email protected]>2021-03-08 18:48:27 +0100
commit8a30a2408c992774f42b55cd62e651c770b07eea (patch)
treee3ec229f4799c1d1a20832f654fa8b0eb7d3f712 /src
parent3e6f0d7372268545e56ced5515764e1176d95d70 (diff)
downloadraylib-8a30a2408c992774f42b55cd62e651c770b07eea.tar.gz
raylib-8a30a2408c992774f42b55cd62e651c770b07eea.zip
ADDED: Required callbacks
Removed memory allocation callbacks
Diffstat (limited to 'src')
-rw-r--r--src/raylib.h8
-rw-r--r--src/utils.c27
2 files changed, 6 insertions, 29 deletions
diff --git a/src/raylib.h b/src/raylib.h
index 5696be2a..659cbc74 100644
--- a/src/raylib.h
+++ b/src/raylib.h
@@ -876,11 +876,6 @@ typedef enum {
// Callbacks to hook some internal functions
// WARNING: This callbacks are intended for advance users
typedef void (*TraceLogCallback)(int logType, const char *text, va_list args); // Logging: Redirect trace log messages
-
-typedef void *(*MemAllocCallback)(int size); // Memory: Custom allocator
-typedef void *(*MemReallocCallback)(void *ptr, int size); // Memory: Custom re-allocator
-typedef void (*MemFreeCallback)(void *ptr); // Memory: Custom free
-
typedef unsigned char* (*LoadFileDataCallback)(const char* fileName, unsigned int* bytesRead); // FileIO: Load binary data
typedef void (*SaveFileDataCallback)(const char *fileName, void *data, unsigned int bytesToWrite); // FileIO: Save binary data
typedef char *(*LoadFileTextCallback)(const char* fileName); // FileIO: Load text data
@@ -991,9 +986,6 @@ RLAPI void MemFree(void *ptr); // Internal me
// Set custom callbacks
// WARNING: Callbacks setup is intended for advance users
RLAPI void SetTraceLogCallback(TraceLogCallback callback); // Set custom trace log
-RLAPI void SetMemAllocCallback(MemAllocCallback callback); // Set custom memory allocator
-RLAPI void SetMemReallocCallback(MemReallocCallback callback); // Set custom memory reallocator
-RLAPI void SetMemFreeCallback(MemFreeCallback callback); // Set custom memory free
RLAPI void SetLoadFileDataCallback(LoadFileDataCallback callback); // Set custom file binary data loader
RLAPI void SetSaveFileDataCallback(SaveFileDataCallback callback); // Set custom file binary data saver
RLAPI void SetLoadFileTextCallback(LoadFileTextCallback callback); // Set custom file text data loader
diff --git a/src/utils.c b/src/utils.c
index 568c6c88..9579346e 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -63,26 +63,18 @@
//----------------------------------------------------------------------------------
// Global Variables Definition
//----------------------------------------------------------------------------------
-
-// Log types messages
static int logTypeLevel = LOG_INFO; // Minimum log type level
static TraceLogCallback traceLog = NULL; // TraceLog callback function pointer
-static MemAllocCallback memAlloc = NULL; // MemAlloc callback function pointer
-static MemReallocCallback memRealloc = NULL; // MemRealloc callback funtion pointer
-static MemFreeCallback memFree = NULL; // MemFree callback funtion pointer
static LoadFileDataCallback loadFileData = NULL; // LoadFileData callback funtion pointer
static SaveFileDataCallback saveFileData = NULL; // SaveFileText callback funtion pointer
static LoadFileTextCallback loadFileText = NULL; // LoadFileText callback funtion pointer
static SaveFileTextCallback saveFileText = NULL; // SaveFileText callback funtion pointer
-//void *MemAllocDefault(unsigned int size) { return RL_MALLOC(size); }
-//void MemFreeDefault(void *ptr) { RL_FREE(ptr); }
-
+//----------------------------------------------------------------------------------
+// Functions to set internal callbacks
+//----------------------------------------------------------------------------------
void SetTraceLogCallback(TraceLogCallback callback) { traceLog = callback; } // Set custom trace log
-void SetMemAllocCallback(MemAllocCallback callback) { memAlloc = callback; } // Set custom memory allocator
-void SetMemReallocCallback(MemReallocCallback callback) { memRealloc = callback; } // Set custom memory reallocator
-void SetMemFreeCallback(MemFreeCallback callback) { memFree = callback; } // Set custom memory free
void SetLoadFileDataCallback(LoadFileDataCallback callback) { loadFileData = callback; } // Set custom file data loader
void SetSaveFileDataCallback(SaveFileDataCallback callback) { saveFileData = callback; } // Set custom file data saver
void SetLoadFileTextCallback(LoadFileTextCallback callback) { loadFileText = callback; } // Set custom file text loader
@@ -172,28 +164,21 @@ void TraceLog(int logType, const char *text, ...)
// NOTE: Initializes to zero by default
void *MemAlloc(int size)
{
- // WARNING: This implementation allows changing memAlloc at any
- // point during program execution, it could be a security risk
- void *ptr = NULL;
- if (memAlloc) ptr = memAlloc(size);
- else ptr = RL_CALLOC(size, 1);
+ void *ptr = RL_CALLOC(size, 1);
return ptr;
}
// Internal memory reallocator
void *MemRealloc(void *ptr, int size)
{
- void *ret = NULL;
- if (memRealloc) ret = memRealloc(ptr, size);
- else ret = RL_REALLOC(ptr, size);
+ void *ret = RL_REALLOC(ptr, size);
return ret;
}
// Internal memory free
void MemFree(void *ptr)
{
- if (memFree) memFree(ptr);
- else RL_FREE(ptr);
+ RL_FREE(ptr);
}
// Load data from file into a buffer