diff options
author | Axel Beckert <abe@deuxchevaux.org> | 2022-04-11 00:18:04 +0200 |
---|---|---|
committer | Axel Beckert <abe@deuxchevaux.org> | 2022-04-11 00:18:04 +0200 |
commit | 31bcc5c263aea983e967426e2b94269e7605dcd4 (patch) | |
tree | 7b48ad9d7799afe09b7d7d8adc980bd5db935bdf /Src/linklist.c | |
parent | 5086b5356abcef8849dc8a09902b7c55f01db3c0 (diff) | |
parent | b09f4483416c54c1782824633dfabaf2ec0265b6 (diff) | |
download | zsh-31bcc5c263aea983e967426e2b94269e7605dcd4.tar.gz zsh-31bcc5c263aea983e967426e2b94269e7605dcd4.zip |
Update upstream source from tag 'upstream/5.8.1.2-test'
Update to upstream version '5.8.1.2-test'
with Debian dir b380d582bf51cd93149e4dea28fffa1ad85db4f5
Diffstat (limited to 'Src/linklist.c')
-rw-r--r-- | Src/linklist.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Src/linklist.c b/Src/linklist.c index 85d9bb367..f64685d9e 100644 --- a/Src/linklist.c +++ b/Src/linklist.c @@ -438,22 +438,27 @@ hlinklist2array(LinkList list, int copy) /* * Convert a linked list whose data elements are strings to - * an array. The result is a permanently allocated, freearrayable - * array. + * a permanently-allocated array. The elements of the array are the same + * elements as the linked list data if copy is 0, else they are duplicated + * into permanent memory so the result is a permanently allocated, + * freearrayable array that's a deep copy of the linked list. */ /**/ mod_export char ** -zlinklist2array(LinkList list) +zlinklist2array(LinkList list, int copy) { int l = countlinknodes(list); char **ret = (char **) zalloc((l + 1) * sizeof(char *)), **p; LinkNode n; for (n = firstnode(list), p = ret; n; incnode(n), p++) { - *p = ztrdup((char *) getdata(n)); + *p = (char *) getdata(n); + if (copy) + *p = ztrdup(*p); } *p = NULL; return ret; } + |