Browse Source

ADDED: MemAlloc() / MemFree() #1440

Exposing internal memory allocator/free, useful for advance users when required
Ray 4 years ago
parent
commit
d2d72b1dfb
2 changed files with 14 additions and 0 deletions
  1. 2 0
      src/raylib.h
  2. 12 0
      src/utils.c

+ 2 - 0
src/raylib.h

@@ -972,6 +972,8 @@ RLAPI void SetTraceLogExit(int logType);                          // Set the exi
 RLAPI void SetTraceLogCallback(TraceLogCallback callback);        // Set a trace log callback to enable custom logging
 RLAPI void TraceLog(int logType, const char *text, ...);          // Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR)
 
+RLAPI void *MemAlloc(int size);                                   // Internal memory allocator
+RLAPI void MemFree(void *ptr);                                    // Internal memory free
 RLAPI void TakeScreenshot(const char *fileName);                  // Takes a screenshot of current screen (saved a .png)
 RLAPI int GetRandomValue(int min, int max);                       // Returns a random value between min and max (both included)
 

+ 12 - 0
src/utils.c

@@ -163,6 +163,18 @@ void TraceLog(int logType, const char *text, ...)
 #endif  // SUPPORT_TRACELOG
 }
 
+// Internal memory allocator
+void *MemAlloc(int size)
+{
+    return RL_MALLOC(size);
+}
+
+// Internal memory free
+void MemFree(void *ptr)
+{
+    RL_FREE(ptr);
+}
+
 // Load data from file into a buffer
 unsigned char *LoadFileData(const char *fileName, unsigned int *bytesRead)
 {