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);
|
remote = strquote(remote);
|
||||||
if (!remote) {
|
if (!remote) {
|
||||||
free((void *) local);
|
SDL_free((void *) local);
|
||||||
return PROCESS_NONE;
|
return PROCESS_NONE;
|
||||||
}
|
}
|
||||||
#endif
|
#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));
|
process_t proc = adb_execute(serial, adb_cmd, ARRAY_LEN(adb_cmd));
|
||||||
|
|
||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
free((void *) remote);
|
SDL_free((void *) remote);
|
||||||
free((void *) local);
|
SDL_free((void *) local);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return proc;
|
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));
|
process_t proc = adb_execute(serial, adb_cmd, ARRAY_LEN(adb_cmd));
|
||||||
|
|
||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
free((void *) local);
|
SDL_free((void *) local);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return proc;
|
return proc;
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
# include <tchar.h>
|
# include <tchar.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <SDL2/SDL_stdinc.h>
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
xstrncpy(char *dest, const char *src, size_t n) {
|
xstrncpy(char *dest, const char *src, size_t n) {
|
||||||
size_t i;
|
size_t i;
|
||||||
@ -45,7 +47,7 @@ truncated:
|
|||||||
char *
|
char *
|
||||||
strquote(const char *src) {
|
strquote(const char *src) {
|
||||||
size_t len = strlen(src);
|
size_t len = strlen(src);
|
||||||
char *quoted = malloc(len + 3);
|
char *quoted = SDL_malloc(len + 3);
|
||||||
if (!quoted) {
|
if (!quoted) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -65,7 +67,7 @@ utf8_to_wide_char(const char *utf8) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
wchar_t *wide = malloc(len * sizeof(wchar_t));
|
wchar_t *wide = SDL_malloc(len * sizeof(wchar_t));
|
||||||
if (!wide) {
|
if (!wide) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
static struct frame_meta *
|
static struct frame_meta *
|
||||||
frame_meta_new(uint64_t pts) {
|
frame_meta_new(uint64_t pts) {
|
||||||
struct frame_meta *meta = malloc(sizeof(*meta));
|
struct frame_meta *meta = SDL_malloc(sizeof(*meta));
|
||||||
if (!meta) {
|
if (!meta) {
|
||||||
return meta;
|
return meta;
|
||||||
}
|
}
|
||||||
@ -35,7 +35,7 @@ frame_meta_new(uint64_t pts) {
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
frame_meta_delete(struct frame_meta *frame_meta) {
|
frame_meta_delete(struct frame_meta *frame_meta) {
|
||||||
free(frame_meta);
|
SDL_free(frame_meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
@ -44,7 +44,7 @@ cmd_execute(const char *path, const char *const argv[], HANDLE *handle) {
|
|||||||
#endif
|
#endif
|
||||||
if (!CreateProcessW(NULL, wide, NULL, NULL, FALSE, flags, NULL, NULL, &si,
|
if (!CreateProcessW(NULL, wide, NULL, NULL, FALSE, flags, NULL, NULL, &si,
|
||||||
&pi)) {
|
&pi)) {
|
||||||
free(wide);
|
SDL_free(wide);
|
||||||
*handle = NULL;
|
*handle = NULL;
|
||||||
if (GetLastError() == ERROR_FILE_NOT_FOUND) {
|
if (GetLastError() == ERROR_FILE_NOT_FOUND) {
|
||||||
return PROCESS_ERROR_MISSING_BINARY;
|
return PROCESS_ERROR_MISSING_BINARY;
|
||||||
@ -52,7 +52,7 @@ cmd_execute(const char *path, const char *const argv[], HANDLE *handle) {
|
|||||||
return PROCESS_ERROR_GENERIC;
|
return PROCESS_ERROR_GENERIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(wide);
|
SDL_free(wide);
|
||||||
*handle = pi.hProcess;
|
*handle = pi.hProcess;
|
||||||
return PROCESS_SUCCESS;
|
return PROCESS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user