From c07798feb5475b47562d6f9e90a564fc1121d25e Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 26 Apr 2016 23:17:02 +0200 Subject: Add, and use, libzahl_memfailure for conciseness, also fix possible unset errno MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/internals.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/internals.h') diff --git a/src/internals.h b/src/internals.h index 6454a21..40dd74d 100644 --- a/src/internals.h +++ b/src/internals.h @@ -134,6 +134,14 @@ libzahl_failure(int error) longjmp(libzahl_jmp_buf, 1); } +static inline void +libzahl_memfailure() +{ + if (!errno) /* sigh... */ + errno = ENOENT; + libzahl_failure(errno); +} + static inline void zmemcpy(zahl_char_t *restrict d, const zahl_char_t *restrict s, register size_t n) { @@ -322,9 +330,7 @@ zinit_temp(z_t a) libzahl_temp_stack = realloc(old, 2 * n * sizeof(*libzahl_temp_stack)); if (unlikely(!libzahl_temp_stack)) { libzahl_temp_stack = old; - if (!errno) /* sigh... */ - errno = ENOMEM; - libzahl_failure(errno); + libzahl_memfailure(); } libzahl_temp_stack_head = libzahl_temp_stack + n; libzahl_temp_stack_end = libzahl_temp_stack_head + n; -- cgit v1.2.3-70-g09d2