Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d5f23af

Browse files
committed
Add const qualifiers to node inspection functions
Thomas Munro
1 parent 0d0ec52 commit d5f23af

File tree

12 files changed

+913
-913
lines changed

12 files changed

+913
-913
lines changed

src/backend/nodes/copyfuncs.c

+259-259
Large diffs are not rendered by default.

src/backend/nodes/equalfuncs.c

+182-182
Large diffs are not rendered by default.

src/backend/nodes/list.c

+37-37
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* Check that the specified List is valid (so far as we can tell).
3232
*/
3333
static void
34-
check_list_invariants(List *list)
34+
check_list_invariants(const List *list)
3535
{
3636
if (list == NIL)
3737
return;
@@ -383,7 +383,7 @@ list_truncate(List *list, int new_size)
383383
* failure if there is no such cell.
384384
*/
385385
static ListCell *
386-
list_nth_cell(List *list, int n)
386+
list_nth_cell(const List *list, int n)
387387
{
388388
ListCell *match;
389389

@@ -407,7 +407,7 @@ list_nth_cell(List *list, int n)
407407
* specified list. (List elements begin at 0.)
408408
*/
409409
void *
410-
list_nth(List *list, int n)
410+
list_nth(const List *list, int n)
411411
{
412412
Assert(IsPointerList(list));
413413
return lfirst(list_nth_cell(list, n));
@@ -418,7 +418,7 @@ list_nth(List *list, int n)
418418
* specified list.
419419
*/
420420
int
421-
list_nth_int(List *list, int n)
421+
list_nth_int(const List *list, int n)
422422
{
423423
Assert(IsIntegerList(list));
424424
return lfirst_int(list_nth_cell(list, n));
@@ -429,7 +429,7 @@ list_nth_int(List *list, int n)
429429
* list.
430430
*/
431431
Oid
432-
list_nth_oid(List *list, int n)
432+
list_nth_oid(const List *list, int n)
433433
{
434434
Assert(IsOidList(list));
435435
return lfirst_oid(list_nth_cell(list, n));
@@ -441,9 +441,9 @@ list_nth_oid(List *list, int n)
441441
* Node as 'datum'.
442442
*/
443443
bool
444-
list_member(List *list, void *datum)
444+
list_member(const List *list, const void *datum)
445445
{
446-
ListCell *cell;
446+
const ListCell *cell;
447447

448448
Assert(IsPointerList(list));
449449
check_list_invariants(list);
@@ -462,9 +462,9 @@ list_member(List *list, void *datum)
462462
* determined by using simple pointer comparison.
463463
*/
464464
bool
465-
list_member_ptr(List *list, void *datum)
465+
list_member_ptr(const List *list, const void *datum)
466466
{
467-
ListCell *cell;
467+
const ListCell *cell;
468468

469469
Assert(IsPointerList(list));
470470
check_list_invariants(list);
@@ -482,9 +482,9 @@ list_member_ptr(List *list, void *datum)
482482
* Return true iff the integer 'datum' is a member of the list.
483483
*/
484484
bool
485-
list_member_int(List *list, int datum)
485+
list_member_int(const List *list, int datum)
486486
{
487-
ListCell *cell;
487+
const ListCell *cell;
488488

489489
Assert(IsIntegerList(list));
490490
check_list_invariants(list);
@@ -502,9 +502,9 @@ list_member_int(List *list, int datum)
502502
* Return true iff the OID 'datum' is a member of the list.
503503
*/
504504
bool
505-
list_member_oid(List *list, Oid datum)
505+
list_member_oid(const List *list, Oid datum)
506506
{
507-
ListCell *cell;
507+
const ListCell *cell;
508508

509509
Assert(IsOidList(list));
510510
check_list_invariants(list);
@@ -694,10 +694,10 @@ list_delete_first(List *list)
694694
* performance bottleneck.
695695
*/
696696
List *
697-
list_union(List *list1, List *list2)
697+
list_union(const List *list1, const List *list2)
698698
{
699699
List *result;
700-
ListCell *cell;
700+
const ListCell *cell;
701701

702702
Assert(IsPointerList(list1));
703703
Assert(IsPointerList(list2));
@@ -718,10 +718,10 @@ list_union(List *list1, List *list2)
718718
* pointer comparison.
719719
*/
720720
List *
721-
list_union_ptr(List *list1, List *list2)
721+
list_union_ptr(const List *list1, const List *list2)
722722
{
723723
List *result;
724-
ListCell *cell;
724+
const ListCell *cell;
725725

726726
Assert(IsPointerList(list1));
727727
Assert(IsPointerList(list2));
@@ -741,10 +741,10 @@ list_union_ptr(List *list1, List *list2)
741741
* This variant of list_union() operates upon lists of integers.
742742
*/
743743
List *
744-
list_union_int(List *list1, List *list2)
744+
list_union_int(const List *list1, const List *list2)
745745
{
746746
List *result;
747-
ListCell *cell;
747+
const ListCell *cell;
748748

749749
Assert(IsIntegerList(list1));
750750
Assert(IsIntegerList(list2));
@@ -764,10 +764,10 @@ list_union_int(List *list1, List *list2)
764764
* This variant of list_union() operates upon lists of OIDs.
765765
*/
766766
List *
767-
list_union_oid(List *list1, List *list2)
767+
list_union_oid(const List *list1, const List *list2)
768768
{
769769
List *result;
770-
ListCell *cell;
770+
const ListCell *cell;
771771

772772
Assert(IsOidList(list1));
773773
Assert(IsOidList(list2));
@@ -797,10 +797,10 @@ list_union_oid(List *list1, List *list2)
797797
* to in the result.
798798
*/
799799
List *
800-
list_intersection(List *list1, List *list2)
800+
list_intersection(const List *list1, const List *list2)
801801
{
802802
List *result;
803-
ListCell *cell;
803+
const ListCell *cell;
804804

805805
if (list1 == NIL || list2 == NIL)
806806
return NIL;
@@ -829,9 +829,9 @@ list_intersection(List *list1, List *list2)
829829
* membership via equal()
830830
*/
831831
List *
832-
list_difference(List *list1, List *list2)
832+
list_difference(const List *list1, const List *list2)
833833
{
834-
ListCell *cell;
834+
const ListCell *cell;
835835
List *result = NIL;
836836

837837
Assert(IsPointerList(list1));
@@ -855,9 +855,9 @@ list_difference(List *list1, List *list2)
855855
* simple pointer equality.
856856
*/
857857
List *
858-
list_difference_ptr(List *list1, List *list2)
858+
list_difference_ptr(const List *list1, const List *list2)
859859
{
860-
ListCell *cell;
860+
const ListCell *cell;
861861
List *result = NIL;
862862

863863
Assert(IsPointerList(list1));
@@ -880,9 +880,9 @@ list_difference_ptr(List *list1, List *list2)
880880
* This variant of list_difference() operates upon lists of integers.
881881
*/
882882
List *
883-
list_difference_int(List *list1, List *list2)
883+
list_difference_int(const List *list1, const List *list2)
884884
{
885-
ListCell *cell;
885+
const ListCell *cell;
886886
List *result = NIL;
887887

888888
Assert(IsIntegerList(list1));
@@ -905,9 +905,9 @@ list_difference_int(List *list1, List *list2)
905905
* This variant of list_difference() operates upon lists of OIDs.
906906
*/
907907
List *
908-
list_difference_oid(List *list1, List *list2)
908+
list_difference_oid(const List *list1, const List *list2)
909909
{
910-
ListCell *cell;
910+
const ListCell *cell;
911911
List *result = NIL;
912912

913913
Assert(IsOidList(list1));
@@ -1131,7 +1131,7 @@ list_free_deep(List *list)
11311131
* Return a shallow copy of the specified list.
11321132
*/
11331133
List *
1134-
list_copy(List *oldlist)
1134+
list_copy(const List *oldlist)
11351135
{
11361136
List *newlist;
11371137
ListCell *newlist_prev;
@@ -1174,7 +1174,7 @@ list_copy(List *oldlist)
11741174
* Return a shallow copy of the specified list, without the first N elements.
11751175
*/
11761176
List *
1177-
list_copy_tail(List *oldlist, int nskip)
1177+
list_copy_tail(const List *oldlist, int nskip)
11781178
{
11791179
List *newlist;
11801180
ListCell *newlist_prev;
@@ -1230,7 +1230,7 @@ list_copy_tail(List *oldlist, int nskip)
12301230
#ifndef USE_INLINE
12311231

12321232
ListCell *
1233-
list_head(List *l)
1233+
list_head(const List *l)
12341234
{
12351235
return l ? l->head : NULL;
12361236
}
@@ -1242,7 +1242,7 @@ list_tail(List *l)
12421242
}
12431243

12441244
int
1245-
list_length(List *l)
1245+
list_length(const List *l)
12461246
{
12471247
return l ? l->length : 0;
12481248
}
@@ -1264,10 +1264,10 @@ list_length(List *l)
12641264
* list_length() macro in order to avoid the overhead of a function
12651265
* call.
12661266
*/
1267-
int length(List *list);
1267+
int length(const List *list);
12681268

12691269
int
1270-
length(List *list)
1270+
length(const List *list)
12711271
{
12721272
return list_length(list);
12731273
}

0 commit comments

Comments
 (0)