diff options
author | Roy Marples <roy@marples.name> | 2007-09-18 15:43:19 +0000 |
---|---|---|
committer | Roy Marples <roy@marples.name> | 2007-09-18 15:43:19 +0000 |
commit | 81c009e47d3a0779cee32e2a90e5a479bbaa790e (patch) | |
tree | 93aa10317db2ef70e8773e2168c5f1006c18d26e /src/librc-strlist.c | |
parent | 9587d71df3c50b26e8e09a74c6d884a965dafafa (diff) |
Don't be an ass - don't free the 2nd list. Instead just empty it.
Diffstat (limited to 'src/librc-strlist.c')
-rw-r--r-- | src/librc-strlist.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/src/librc-strlist.c b/src/librc-strlist.c index dc9bc20c..14d08baa 100644 --- a/src/librc-strlist.c +++ b/src/librc-strlist.c @@ -142,16 +142,10 @@ int rc_strlist_join (char ***list1, char **list2) int i = 0; int j = 0; - if (! lst1 && list2) { - *list1 = list2; - return (0); - } - if (! list2 && lst1) - return (0); - if (! lst1 && ! list2) + if (! list2) return (0); - while (lst1[i]) + while (lst1 && lst1[i]) i++; while (list2[j]) @@ -162,14 +156,13 @@ int rc_strlist_join (char ***list1, char **list2) j = 0; while (list2[j]) { newlist[i] = list2[j]; + /* Take the item off the 2nd list as it's only a shallow copy */ + list2[j] = NULL; i++; j++; } newlist[i] = NULL; - /* We free list2 here for ease of use. */ - free (list2); - *list1 = newlist; return (0); } |