diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-12-08 19:28:41 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-12-08 19:28:41 +0100 |
commit | 718a400d599f3df3a64c2c0659a48fb9d22b6105 (patch) | |
tree | 48041ab3edec8580781fc37c201f6fb7e6794d51 /src/libmdsserver/linked-list.c | |
parent | no more goto fail (diff) | |
download | mds-718a400d599f3df3a64c2c0659a48fb9d22b6105.tar.gz mds-718a400d599f3df3a64c2c0659a48fb9d22b6105.tar.bz2 mds-718a400d599f3df3a64c2c0659a48fb9d22b6105.tar.xz |
m + make sure we never lose errno
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r-- | src/libmdsserver/linked-list.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/libmdsserver/linked-list.c b/src/libmdsserver/linked-list.c index 83f7711..d17ba8b 100644 --- a/src/libmdsserver/linked-list.c +++ b/src/libmdsserver/linked-list.c @@ -116,6 +116,7 @@ int linked_list_clone(const linked_list_t* restrict this, linked_list_t* restric ssize_t* restrict new_next = NULL; ssize_t* restrict new_previous = NULL; ssize_t* restrict new_reusable; + int saved_errno; out->values = NULL; out->next = NULL; @@ -145,10 +146,11 @@ int linked_list_clone(const linked_list_t* restrict this, linked_list_t* restric return 0; pfail: + saved_errno = errno; free(new_values); free(new_next); free(new_previous); - return -1; + return errno = saved_errno, -1; } @@ -177,6 +179,7 @@ int linked_list_pack(linked_list_t* restrict this) size_t i = 0; ssize_t node; size_t* restrict vals; + int saved_errno; if (xmalloc(vals, cap, size_t)) return -1; @@ -219,10 +222,11 @@ int linked_list_pack(linked_list_t* restrict this) return 0; pfail: + saved_errno = errno; free(vals); free(new_next); free(new_previous); - return -1; + return errno = saved_errno, -1; } |