Always use SDL_malloc() and SDL_free()

To avoid mixing SDL_malloc()/SDL_strdup() with free(), or malloc() with
SDL_free(), always use the SDL version.
This commit is contained in:
Romain Vimont
2019-05-30 00:10:45 +02:00
parent 7ed976967f
commit 3bc1c51b91
4 changed files with 12 additions and 10 deletions

View File

@@ -8,6 +8,8 @@
# include <tchar.h>
#endif
#include <SDL2/SDL_stdinc.h>
size_t
xstrncpy(char *dest, const char *src, size_t n) {
size_t i;
@@ -45,7 +47,7 @@ truncated:
char *
strquote(const char *src) {
size_t len = strlen(src);
char *quoted = malloc(len + 3);
char *quoted = SDL_malloc(len + 3);
if (!quoted) {
return NULL;
}
@@ -65,7 +67,7 @@ utf8_to_wide_char(const char *utf8) {
return NULL;
}
wchar_t *wide = malloc(len * sizeof(wchar_t));
wchar_t *wide = SDL_malloc(len * sizeof(wchar_t));
if (!wide) {
return NULL;
}