1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-07 12:30:27 +00:00

Replace malloc's with Godot's memalloc macro

(cherry picked from commit 838e7d0a8d)
This commit is contained in:
Ev1lbl0w
2021-03-10 18:31:44 +00:00
committed by Rémi Verschelde
parent 7ca7acce7b
commit a586f9daae
6 changed files with 37 additions and 25 deletions

View File

@@ -172,9 +172,11 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_setup(JNIEnv *env, jc
if (p_cmdline) {
cmdlen = env->GetArrayLength(p_cmdline);
if (cmdlen) {
cmdline = (const char **)malloc((cmdlen + 1) * sizeof(const char *));
cmdline = (const char **)memalloc((cmdlen + 1) * sizeof(const char *));
ERR_FAIL_NULL_MSG(cmdline, "Out of memory.");
cmdline[cmdlen] = NULL;
j_cmdline = (jstring *)malloc(cmdlen * sizeof(jstring));
j_cmdline = (jstring *)memalloc(cmdlen * sizeof(jstring));
ERR_FAIL_NULL_MSG(j_cmdline, "Out of memory.");
for (int i = 0; i < cmdlen; i++) {
@@ -193,9 +195,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_setup(JNIEnv *env, jc
for (int i = 0; i < cmdlen; ++i) {
env->ReleaseStringUTFChars(j_cmdline[i], cmdline[i]);
}
free(j_cmdline);
memfree(j_cmdline);
}
free(cmdline);
memfree(cmdline);
}
if (err != OK) {