used RL_MALLOC

This commit is contained in:
DissolveDZ 2023-09-30 20:19:56 +02:00
parent 6783b3ebd6
commit d62d4c3309

View File

@ -1367,7 +1367,7 @@ const char *TextFormat(const char *format, ...)
return NULL; return NULL;
} }
char *result = (char *)malloc(length + 1); // Allocate memory for the formatted string (+1 for null terminator) char *result = (char *)RL_MALLOC(length + 1); // Allocate memory for the formatted string (+1 for null terminator)
if (result == NULL) if (result == NULL)
{ {
// Handle memory allocation failure // Handle memory allocation failure
@ -1380,7 +1380,6 @@ const char *TextFormat(const char *format, ...)
va_start(args, format); // Start again for the actual formatting va_start(args, format); // Start again for the actual formatting
vsnprintf(result, length + 1, format, args); // Format the string and copy it to the result buffer vsnprintf(result, length + 1, format, args); // Format the string and copy it to the result buffer
va_end(args); va_end(args);
return result; return result;
} }
@ -1454,11 +1453,12 @@ const char *TextSubtext(const char *text, int position, int length)
if (length > textLength) if (length > textLength)
length = textLength; length = textLength;
char *buffer = malloc(length + 1); char *buffer = RL_MALLOC(length + 1);
memcpy(buffer, text + position, length); memcpy(buffer, text + position, length);
buffer[length] = '\0'; buffer[length] = '\0';
// strcpy(text, buffer);
return buffer; // free(buffer);
return text;
} }
// Replace text string // Replace text string