aboutsummaryrefslogtreecommitdiff
path: root/linux-user/main.c
diff options
context:
space:
mode:
authorSaurav Sachidanand <sauravsachidanand@gmail.com>2017-03-20 17:38:28 +0000
committerMichael Tokarev <mjt@tls.msk.ru>2017-05-07 09:57:51 +0300
commitec45bbe5f1921c6553fbf9c0c76b358b0403c22d (patch)
tree82c4bf0052387088ff03cbfec17a633b05b2be92 /linux-user/main.c
parent9879f5ac62c1e0c92a5ff2f4a0ada1b66d43da90 (diff)
util: Use g_malloc/g_free in envlist.c
Change malloc/strdup/free to g_malloc/g_strdup/g_free in util/envlist.c. Remove NULL checks for pointers returned from g_malloc and g_strdup as they exit in case of failure. Also, update calls to envlist_create to reflect this. Free array and array contents returned by envlist_to_environ using g_free in bsd-user/main.c and linux-user/main.c. Update comments to reflect change in semantics. Signed-off-by: Saurav Sachidanand <sauravsachidanand@gmail.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Diffstat (limited to 'linux-user/main.c')
-rw-r--r--linux-user/main.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/linux-user/main.c b/linux-user/main.c
index 10a3bb3a12..5f20769cb9 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -4229,10 +4229,7 @@ int main(int argc, char **argv, char **envp)
qemu_init_cpu_list();
module_call_init(MODULE_INIT_QOM);
- if ((envlist = envlist_create()) == NULL) {
- (void) fprintf(stderr, "Unable to allocate envlist\n");
- exit(EXIT_FAILURE);
- }
+ envlist = envlist_create();
/* add current environment into the list */
for (wrk = environ; *wrk != NULL; wrk++) {
@@ -4429,10 +4426,10 @@ int main(int argc, char **argv, char **envp)
}
for (wrk = target_environ; *wrk; wrk++) {
- free(*wrk);
+ g_free(*wrk);
}
- free(target_environ);
+ g_free(target_environ);
if (qemu_loglevel_mask(CPU_LOG_PAGE)) {
qemu_log("guest_base 0x%lx\n", guest_base);