1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Replace malloc's with Godot's memalloc macro

This commit is contained in:
Ev1lbl0w
2021-03-10 18:31:44 +00:00
parent 01851defb5
commit 838e7d0a8d
6 changed files with 37 additions and 26 deletions

View File

@@ -127,9 +127,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] = nullptr;
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++) {
jstring string = (jstring)env->GetObjectArrayElement(p_cmdline, i);
@@ -147,9 +149,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) {