Browse Source

Review custom allocators

pull/1092/head
raysan5 5 years ago
parent
commit
bec467705e
4 changed files with 10 additions and 4 deletions
  1. +3
    -0
      src/raylib.h
  2. +4
    -1
      src/rlgl.h
  3. +1
    -1
      src/text.c
  4. +2
    -2
      src/textures.c

+ 3
- 0
src/raylib.h View File

@ -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

+ 4
- 1
src/rlgl.h View File

@ -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");

+ 1
- 1
src/text.c View File

@ -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;
}

+ 2
- 2
src/textures.c View File

@ -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)
{

Loading…
Cancel
Save