As part of the AIO work [1], there are quite a number of dlist_heads
which a counter is used to keep track on how many items are in the
list. We also have a few places in master which do the same thing.
In order to tidy this up and to help ensure that the count variable
does not get out of sync with the items which are stored in the list,
how about we introduce "dclist" which maintains the count for us?
I've attached a patch which does this. The majority of the functions
for the new type are just wrappers around the equivalent dlist
function.
dclist provides all of the functionality that dlist does except
there's no dclist_delete() function. dlist_delete() can be done by
just knowing the element to delete and not the list that the element
belongs to. With dclist, that's not possible as we must also subtract
1 from the count variable and obviously we need the dclist_head for
that.
I'll add this to the November commitfest.
David
[1] https://www.postgresql.org/message-id/flat/20210223100344.llw5an2aklengrmn@alap3.anarazel.de