diff --git a/.gitignore b/.gitignore index ad5ae32..ae712b5 100644 --- a/.gitignore +++ b/.gitignore @@ -122,3 +122,5 @@ build/uwp/sdl-gpu-static/Release Pro/ build/uwp/sdl-gpu-static/ARM/ build/uwp/sdl-gpu-static/x64/ build/uwp/tic/packages/ +build/windows/studio/x64/ +build/windows/sdl-gpu/x64/ diff --git a/src/code.c b/src/code.c index de97b6c..47daef3 100644 --- a/src/code.c +++ b/src/code.c @@ -590,7 +590,7 @@ static void copyFromClipboard(Code* code) parseSyntaxColor(code); } - free(clipboard); + getSystem()->freeClipboardText(clipboard); } } } diff --git a/src/map.c b/src/map.c index 6fee908..b82a89f 100644 --- a/src/map.c +++ b/src/map.c @@ -1004,7 +1004,7 @@ static void copyFromClipboard(Map* map) else free(data); } - free(clipboard); + getSystem()->freeClipboardText(clipboard); } } } diff --git a/src/music.c b/src/music.c index 738b00f..ff75e69 100644 --- a/src/music.c +++ b/src/music.c @@ -651,7 +651,7 @@ static void copyFromClipboard(Music* music) free(data); } - free(clipboard); + getSystem()->freeClipboardText(clipboard); } } } diff --git a/src/studio.c b/src/studio.c index 1d00666..e845e83 100644 --- a/src/studio.c +++ b/src/studio.c @@ -417,7 +417,7 @@ bool fromClipboard(void* data, s32 size, bool flip, bool remove_white_spaces) if(valid) str2buf(clipboard, strlen(clipboard), data, flip); - free(clipboard); + getSystem()->freeClipboardText(clipboard); return valid; } diff --git a/src/system.c b/src/system.c index af49d0c..e19d11c 100644 --- a/src/system.c +++ b/src/system.c @@ -876,6 +876,11 @@ static char* getClipboardText() return SDL_GetClipboardText(); } +static void freeClipboardText(const char* text) +{ + SDL_free((void*)text); +} + static u64 getPerformanceCounter() { return SDL_GetPerformanceCounter(); @@ -1057,6 +1062,8 @@ static System systemInterface = .setClipboardText = setClipboardText, .hasClipboardText = hasClipboardText, .getClipboardText = getClipboardText, + .freeClipboardText = freeClipboardText, + .getPerformanceCounter = getPerformanceCounter, .getPerformanceFrequency = getPerformanceFrequency, diff --git a/src/system.h b/src/system.h index c08768d..1e09e10 100644 --- a/src/system.h +++ b/src/system.h @@ -8,6 +8,8 @@ typedef struct void (*setClipboardText)(const char* text); bool (*hasClipboardText)(); char* (*getClipboardText)(); + void (*freeClipboardText)(const char* text); + u64 (*getPerformanceCounter)(); u64 (*getPerformanceFrequency)(); diff --git a/src/system/chip.c b/src/system/chip.c index cc4f30f..6755a82 100644 --- a/src/system/chip.c +++ b/src/system/chip.c @@ -517,6 +517,11 @@ static char* getClipboardText() return SDL_GetClipboardText(); } +static void freeClipboardText(const char* text) +{ + SDL_free((void*)text); +} + static u64 getPerformanceCounter() { return SDL_GetPerformanceCounter(); @@ -599,6 +604,8 @@ static System systemInterface = .setClipboardText = setClipboardText, .hasClipboardText = hasClipboardText, .getClipboardText = getClipboardText, + .freeClipboardText = freeClipboardText, + .getPerformanceCounter = getPerformanceCounter, .getPerformanceFrequency = getPerformanceFrequency,