linux-user: replace calloc() with g_new0()
authorNguyen Dinh Phi <phind.uet@gmail.com>
Sun, 17 Mar 2024 17:17:47 +0000 (01:17 +0800)
committerRichard Henderson <richard.henderson@linaro.org>
Tue, 9 Apr 2024 17:43:31 +0000 (07:43 -1000)
Use glib allocation as recommended by the coding convention

Signed-off-by: Nguyen Dinh Phi <phind.uet@gmail.com>
Message-Id: <20240317171747.1642207-1-phind.uet@gmail.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
linux-user/main.c

index 9277df2e9ddd2b25501ee4deaffa3fb5e7e91036..149e35432e8f475be677814f4347095afd265cc2 100644 (file)
@@ -928,11 +928,7 @@ int main(int argc, char **argv, char **envp)
      * Prepare copy of argv vector for target.
      */
     target_argc = argc - optind;
-    target_argv = calloc(target_argc + 1, sizeof (char *));
-    if (target_argv == NULL) {
-        (void) fprintf(stderr, "Unable to allocate memory for target_argv\n");
-        exit(EXIT_FAILURE);
-    }
+    target_argv = g_new0(char *, target_argc + 1);
 
     /*
      * If argv0 is specified (using '-0' switch) we replace