summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorraysan5 <[email protected]>2020-01-19 11:23:38 +0100
committerraysan5 <[email protected]>2020-01-19 11:23:38 +0100
commitbec467705e83ecf66f4bf75ddbcad8ac4a9d8e95 (patch)
treee799506eebe2b9af8b44cb8b1bab1e14073c2394 /src
parentfe0d04c8796234d53b474e02dd4d8e198d32ef99 (diff)
downloadraylib-bec467705e83ecf66f4bf75ddbcad8ac4a9d8e95.tar.gz
raylib-bec467705e83ecf66f4bf75ddbcad8ac4a9d8e95.zip
Review custom allocators
Diffstat (limited to 'src')
-rw-r--r--src/raylib.h3
-rw-r--r--src/rlgl.h5
-rw-r--r--src/text.c2
-rw-r--r--src/textures.c4
4 files changed, 10 insertions, 4 deletions
diff --git a/src/raylib.h b/src/raylib.h
index b9ce607d..a86aac86 100644
--- a/src/raylib.h
+++ b/src/raylib.h
@@ -106,6 +106,9 @@
#ifndef RL_CALLOC
#define RL_CALLOC(n,sz) calloc(n,sz)
#endif
+#ifndef RL_REALLOC
+ #define RL_REALLOC(n,sz) realloc(n,sz)
+#endif
#ifndef RL_FREE
#define RL_FREE(p) free(p)
#endif
diff --git a/src/rlgl.h b/src/rlgl.h
index 1d0adc42..349ea50a 100644
--- a/src/rlgl.h
+++ b/src/rlgl.h
@@ -82,6 +82,9 @@
#ifndef RL_CALLOC
#define RL_CALLOC(n,sz) calloc(n,sz)
#endif
+ #ifndef RL_REALLOC
+ #define RL_REALLOC(n,sz) realloc(n,sz)
+ #endif
#ifndef RL_FREE
#define RL_FREE(p) free(p)
#endif
@@ -4482,7 +4485,7 @@ static int GenerateMipmaps(unsigned char *data, int baseWidth, int baseHeight)
TraceLog(LOG_DEBUG, "Total mipmaps required: %i", mipmapCount);
TraceLog(LOG_DEBUG, "Total size of data required: %i", size);
- unsigned char *temp = realloc(data, size);
+ unsigned char *temp = RL_REALLOC(data, size);
if (temp != NULL) data = temp;
else TraceLog(LOG_WARNING, "Mipmaps required memory could not be allocated");
diff --git a/src/text.c b/src/text.c
index 5ff83849..7fe70b86 100644
--- a/src/text.c
+++ b/src/text.c
@@ -1431,7 +1431,7 @@ char *TextToUtf8(int *codepoints, int length)
}
// Resize memory to text length + string NULL terminator
- text = realloc(text, size + 1);
+ text = RL_REALLOC(text, size + 1);
return text;
}
diff --git a/src/textures.c b/src/textures.c
index 19bfd16a..5b0c3971 100644
--- a/src/textures.c
+++ b/src/textures.c
@@ -115,7 +115,7 @@
#define STBI_MALLOC RL_MALLOC
#define STBI_FREE RL_FREE
- #define STBI_REALLOC(p,newsz) realloc(p,newsz)
+ #define STBI_REALLOC RL_REALLOC
#define STB_IMAGE_IMPLEMENTATION
#include "external/stb_image.h" // Required for: stbi_load_from_file()
@@ -1604,7 +1604,7 @@ void ImageMipmaps(Image *image)
if (image->mipmaps < mipCount)
{
- void *temp = realloc(image->data, mipSize);
+ void *temp = RL_REALLOC(image->data, mipSize);
if (temp != NULL)
{