pgsql: Constify fields and parameters in spell.c

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Constify fields and parameters in spell.c
Date: 2024-08-06 20:11:45
Message-ID: E1sbQX3-00315Q-9a@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Constify fields and parameters in spell.c

I started by marking VoidString as const, and fixing the fallout by
marking more fields and function arguments as const. It proliferated
quite a lot, but all within spell.c and spell.h.

A more narrow patch to get rid of the static VoidString buffer would
be to replace it with '#define VoidString ""', as C99 allows assigning
"" to a non-const pointer, even though you're not allowed to modify
it. But it seems like good hygiene to mark all these as const. In the
structs, the pointers can point to the constant VoidString, or a
buffer allocated with palloc(), or with compact_palloc(), so you
should not modify them.

Reviewed-by: Andres Freund
Discussion: https://www.postgresql.org/message-id/54c29fb0-edf2-48ea-9814-44e918bbd6e8@iki.fi

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/d5f139cb6814f0af2d2e1106899361e45c305630

Modified Files
--------------
src/backend/tsearch/spell.c | 58 +++++++++++++++++++++------------------
src/include/tsearch/dicts/spell.h | 16 +++++------
2 files changed, 39 insertions(+), 35 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message noreply 2024-08-06 21:16:26 pgsql: Tag refs/tags/REL_13_16 was created
Previous Message Jeff Davis 2024-08-06 19:25:26 pgsql: selfuncs.c: use pg_strxfrm() instead of strxfrm().