From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43498) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1acGZL-0000it-B7 for qemu-devel@nongnu.org; Sat, 05 Mar 2016 13:04:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1acGZH-0001KC-8Q for qemu-devel@nongnu.org; Sat, 05 Mar 2016 13:04:47 -0500 Received: from mail-wm0-x235.google.com ([2a00:1450:400c:c09::235]:36090) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1acGZH-0001K8-13 for qemu-devel@nongnu.org; Sat, 05 Mar 2016 13:04:43 -0500 Received: by mail-wm0-x235.google.com with SMTP id n186so32059552wmn.1 for ; Sat, 05 Mar 2016 10:04:41 -0800 (PST) Sender: Paolo Bonzini References: <1457160318-5348-1-git-send-email-sarahjmi07@gmail.com> From: Paolo Bonzini Message-ID: <56DB1FB3.2080705@redhat.com> Date: Sat, 5 Mar 2016 19:04:35 +0100 MIME-Version: 1.0 In-Reply-To: <1457160318-5348-1-git-send-email-sarahjmi07@gmail.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH][Outreachy] List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Sarah Khan , qemu-devel@nongnu.org, famz@redhat.com On 05/03/2016 07:45, Sarah Khan wrote: > util/envlist.c:This patch replaces malloc with g_malloc This should be placed in the subject. Please follow the instructions at http://wiki.qemu.org/Contribute/SubmitAPatch#Submitting_your_Patches to format the patch correctly. > - if ((envlist = malloc(sizeof (*envlist))) == NULL) > + if ((envlist = g_malloc(sizeof (*envlist))) == NULL) > return (NULL); g_malloc will never return NULL, so you can remove the if. > - if ((entry = malloc(sizeof (*entry))) == NULL) > + if ((entry = g_malloc(sizeof (*entry))) == NULL) > return (errno); Likewise. > if ((entry->ev_var = strdup(env)) == NULL) { You could also replace strdup with g_strdup... > - free(entry); > + g_free(entry); > return (errno); > } > QLIST_INSERT_HEAD(&envlist->el_entries, entry, ev_link); > @@ -201,8 +201,8 @@ envlist_unsetenv(envlist_t *envlist, const char *env) > } > if (entry != NULL) { > QLIST_REMOVE(entry, ev_link); > - free((char *)entry->ev_var); > - free(entry); > + g_free((char *)entry->ev_var); ... because here you are replacing its freeing with g_free. > + g_free(entry); > > envlist->el_count--; > } > @@ -225,7 +225,7 @@ envlist_to_environ(const envlist_t *envlist, size_t *count) > struct envlist_entry *entry; > char **env, **penv; > > - penv = env = malloc((envlist->el_count + 1) * sizeof (char *)); > + penv = env = g_malloc((envlist->el_count + 1) * sizeof (char *)); > if (env == NULL) > return (NULL); This if can be removed. Note that you have included the patch twice in your message. Thanks, Paolo