From 823a8ca6bf806805acaaf5a7bbe51f129a603980 Mon Sep 17 00:00:00 2001 From: Richard Frith-Macdonald Date: Fri, 20 Jan 2023 14:00:19 +0000 Subject: [PATCH] Links from a link store should be considered owned by that store. --- GSLinkedList.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/GSLinkedList.h b/GSLinkedList.h index 68d179d..ad9a2f1 100644 --- a/GSLinkedList.h +++ b/GSLinkedList.h @@ -387,14 +387,22 @@ GSLinkedListRemove(GSListLink *link, GSLinkedList *list); @end +/** Returns a link to the free list of the store. The link must either have + * been provided by GSLinkStoreProvideLink() or have been removed from the + * store list using GSLinkRemove(). + */ static inline void -GSLinkStoreConsumeLink(GSLinkStore *list, GSListLink NS_CONSUMED *link) +GSLinkStoreConsumeLink(GSLinkStore *list, GSListLink *link) { link->next = list->free; list->free = link; } - -static inline GSListLink* NS_RETURNS_RETAINED + +/** Fetches a link from the free list of the store (allocating if necessary). + * The link is still nominally owned by the store and must be inserted into + * the list or returned to the free list. + */ +static inline GSListLink* GSLinkStoreProvideLink(GSLinkStore *list) { GSListLink *link = list->free;