commit 68c907170c4d36d5cc9c789692ff0e7c025d435c
parent a76d800a28111c7753274bf8f78412a7a88927af
Author: Robert Russell <robertrussell.72001@gmail.com>
Date: Sun, 24 Sep 2023 15:40:16 -0700
Preserve errno in list free
Most implementations of LIST_FREE should do this already, but
let's be safe (and consistent; I do this in the dict implementation).
Diffstat:
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/inc/list/declare.h b/inc/list/declare.h
@@ -1,3 +1,5 @@
+#include <errno.h>
+
#include "../alloc.h"
#include "../def.h"
diff --git a/inc/list/impl/declare.h b/inc/list/impl/declare.h
@@ -11,7 +11,11 @@ LIST_STATIC UNUSED LIST_T LIST_METHOD(del)(LIST_T **l, usize i);
static inline UNUSED void
LIST_METHOD(free)(LIST_T **l) {
- if (*l) LIST_FREE(LIST_HDR(*l));
+ if (*l) {
+ int e = errno;
+ LIST_FREE(LIST_HDR(*l));
+ errno = e;
+ }
*l = 0;
}