summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2023-11-09 14:34:40 -0500
committerTavian Barnes <tavianator@tavianator.com>2023-11-09 15:22:26 -0500
commitffa465b759204272a5e94d851ce3696c827e9d96 (patch)
treedee7ff57530123d3cd2af0d01334449732c71966
parent5fe11b94b38bfb4d43637e05ac24da0d7d72b9ea (diff)
downloadbfs-ffa465b759204272a5e94d851ce3696c827e9d96.tar.xz
list: Simplify slist_remove_impl()
We now assume that all-bits-zero is a null pointer, so memset is fine.
-rw-r--r--src/list.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/list.h b/src/list.h
index 61c22e3..91f416f 100644
--- a/src/list.h
+++ b/src/list.h
@@ -317,15 +317,15 @@
#define SLIST_REMOVE__(list, cursor, next) \
(list->tail = (*cursor)->next ? list->tail : cursor, \
- slist_remove_impl(*cursor, cursor, &(*cursor)->next, list->tail, sizeof(*cursor)))
+ slist_remove_impl(*cursor, cursor, &(*cursor)->next, sizeof(*cursor)))
// Helper for SLIST_REMOVE()
-static inline void *slist_remove_impl(void *ret, void *cursor, void *next, void *tail, size_t size) {
+static inline void *slist_remove_impl(void *ret, void *cursor, void *next, size_t size) {
// ret = *cursor;
// *cursor = ret->next;
memcpy(cursor, next, size);
- // ret->next = *list->tail; (NULL)
- memcpy(next, tail, size);
+ // ret->next = NULL;
+ memset(next, 0, size);
return ret;
}