1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-06 07:49:08 +03:00

Constify the arguments of ilist.c/h functions

Const qualifiers ensure that we don't do something stupid in the
function implementation.  Additionally they clarify the interface.  As
an example:

    void
    slist_delete(slist_head *head, const slist_node *node)

Here one can instantly tell that node->next is not going to be set to
NULL.  Finally, const qualifiers potentially allow the compiler to do
more optimizations.  This being said, no benchmarking was done for
this patch.

The functions that return non-const pointers like slist_next_node(),
dclist_next_node() etc. are not affected by the patch intentionally.

Author: Aleksander Alekseev
Reviewed-by: Andres Freund
Discussion: https://postgr.es/m/CAJ7c6TM2%3D08mNKD9aJg8vEY9hd%2BG4L7%2BNvh30UiNT3kShgRgNg%40mail.gmail.com
This commit is contained in:
Peter Eisentraut
2023-01-12 08:00:51 +01:00
parent 881fa869c6
commit c8ad4d8166
2 changed files with 17 additions and 17 deletions

View File

@@ -28,7 +28,7 @@
* Caution: this is O(n); consider using slist_delete_current() instead.
*/
void
slist_delete(slist_head *head, slist_node *node)
slist_delete(slist_head *head, const slist_node *node)
{
slist_node *last = &head->head;
slist_node *cur;
@@ -57,7 +57,7 @@ slist_delete(slist_head *head, slist_node *node)
* Validate that 'node' is a member of 'head'
*/
void
dlist_member_check(dlist_head *head, dlist_node *node)
dlist_member_check(const dlist_head *head, const dlist_node *node)
{
dlist_iter iter;
@@ -73,7 +73,7 @@ dlist_member_check(dlist_head *head, dlist_node *node)
* Verify integrity of a doubly linked list
*/
void
dlist_check(dlist_head *head)
dlist_check(const dlist_head *head)
{
dlist_node *cur;
@@ -110,7 +110,7 @@ dlist_check(dlist_head *head)
* Verify integrity of a singly linked list
*/
void
slist_check(slist_head *head)
slist_check(const slist_head *head)
{
slist_node *cur;