mirror of
https://github.com/Genymobile/scrcpy
synced 2024-11-15 06:12:53 +00:00
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:
parent
7ed976967f
commit
3bc1c51b91
@ -147,7 +147,7 @@ adb_push(const char *serial, const char *local, const char *remote) {
|
||||
}
|
||||
remote = strquote(remote);
|
||||
if (!remote) {
|
||||
free((void *) local);
|
||||
SDL_free((void *) local);
|
||||
return PROCESS_NONE;
|
||||
}
|
||||
#endif
|
||||
@ -156,8 +156,8 @@ adb_push(const char *serial, const char *local, const char *remote) {
|
||||
process_t proc = adb_execute(serial, adb_cmd, ARRAY_LEN(adb_cmd));
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
free((void *) remote);
|
||||
free((void *) local);
|
||||
SDL_free((void *) remote);
|
||||
SDL_free((void *) local);
|
||||
#endif
|
||||
|
||||
return proc;
|
||||
@ -178,7 +178,7 @@ adb_install(const char *serial, const char *local) {
|
||||
process_t proc = adb_execute(serial, adb_cmd, ARRAY_LEN(adb_cmd));
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
free((void *) local);
|
||||
SDL_free((void *) local);
|
||||
#endif
|
||||
|
||||
return proc;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
static struct frame_meta *
|
||||
frame_meta_new(uint64_t pts) {
|
||||
struct frame_meta *meta = malloc(sizeof(*meta));
|
||||
struct frame_meta *meta = SDL_malloc(sizeof(*meta));
|
||||
if (!meta) {
|
||||
return meta;
|
||||
}
|
||||
@ -35,7 +35,7 @@ frame_meta_new(uint64_t pts) {
|
||||
|
||||
static void
|
||||
frame_meta_delete(struct frame_meta *frame_meta) {
|
||||
free(frame_meta);
|
||||
SDL_free(frame_meta);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
@ -44,7 +44,7 @@ cmd_execute(const char *path, const char *const argv[], HANDLE *handle) {
|
||||
#endif
|
||||
if (!CreateProcessW(NULL, wide, NULL, NULL, FALSE, flags, NULL, NULL, &si,
|
||||
&pi)) {
|
||||
free(wide);
|
||||
SDL_free(wide);
|
||||
*handle = NULL;
|
||||
if (GetLastError() == ERROR_FILE_NOT_FOUND) {
|
||||
return PROCESS_ERROR_MISSING_BINARY;
|
||||
@ -52,7 +52,7 @@ cmd_execute(const char *path, const char *const argv[], HANDLE *handle) {
|
||||
return PROCESS_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
free(wide);
|
||||
SDL_free(wide);
|
||||
*handle = pi.hProcess;
|
||||
return PROCESS_SUCCESS;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user