AmendHub

Download:

jcs

/

subtext

/

amendments

/

275

board: constify fields


jcs made amendment 275 over 2 years ago
--- board.c Fri Sep 16 17:15:11 2022 +++ board.c Tue Nov 8 13:03:12 2022 @@ -30,7 +30,7 @@ #define POST_READ_RETURN_LIST -2 #define POST_READ_RETURN_FIND -3 -struct struct_field board_fields[] = { +const struct struct_field board_fields[] = { { "Board ID", CONFIG_TYPE_LONG, offsetof(struct board, id), 1, ULONG_MAX }, @@ -50,9 +50,9 @@ struct struct_field board_fields[] = { offsetof(struct board, retention_days), 0, USHRT_MAX }, }; -size_t nboard_fields = nitems(board_fields); +const size_t nboard_fields = nitems(board_fields); -struct bile_object_field board_object_fields[] = { +const struct bile_object_field board_object_fields[] = { { offsetof(struct board, id), member_size(struct board, id), -1 }, { offsetof(struct board, name), @@ -70,9 +70,9 @@ struct bile_object_field board_object_fields[] = { { offsetof(struct board, post_count), member_size(struct board, post_count), -1 }, }; -size_t nboard_object_fields = nitems(board_object_fields); +const size_t nboard_object_fields = nitems(board_object_fields); -struct bile_object_field board_post_object_fields[] = { +const struct bile_object_field board_post_object_fields[] = { { offsetof(struct board_post, id), member_size(struct board_post, id), -1 }, { offsetof(struct board_post, thread_id), @@ -90,9 +90,9 @@ struct bile_object_field board_post_object_fields[] = { offsetof(struct board_post, via), member_size(struct board_post, via), -1 }, }; -size_t nboard_post_object_fields = nitems(board_post_object_fields); +const size_t nboard_post_object_fields = nitems(board_post_object_fields); -struct bile_object_field board_thread_object_fields[] = { +const struct bile_object_field board_thread_object_fields[] = { { offsetof(struct board_thread, thread_id), member_size(struct board_thread, thread_id), -1 }, { offsetof(struct board_thread, last_post_at), @@ -108,7 +108,7 @@ struct bile_object_field board_thread_object_fields[] { offsetof(struct board_thread, parent_post_ids), -(sizeof(long)), offsetof(struct board_thread, nposts) }, }; -size_t nboard_thread_object_fields = nitems(board_thread_object_fields); +const size_t nboard_thread_object_fields = nitems(board_thread_object_fields); unsigned long board_compose(struct session *s, struct board *board, struct board_thread *thread, struct board_post *parent_post, --- board.h Fri Sep 16 13:44:29 2022 +++ board.h Tue Nov 8 13:02:37 2022 @@ -36,10 +36,10 @@ struct board { struct bile *bile; }; -extern struct struct_field board_fields[]; -extern size_t nboard_fields; -extern struct bile_object_field board_object_fields[]; -extern size_t nboard_object_fields; +extern const struct struct_field board_fields[]; +extern const size_t nboard_fields; +extern const struct bile_object_field board_object_fields[]; +extern const size_t nboard_object_fields; struct board_post { unsigned long id; @@ -51,8 +51,8 @@ struct board_post { unsigned long parent_post_id; char via[10]; }; -extern struct bile_object_field board_post_object_fields[]; -extern size_t nboard_post_object_fields; +extern const struct bile_object_field board_post_object_fields[]; +extern const size_t nboard_post_object_fields; struct board_thread { unsigned long thread_id; @@ -63,8 +63,8 @@ struct board_thread { unsigned long *post_ids; unsigned long *parent_post_ids; }; -extern struct bile_object_field board_thread_object_fields[]; -extern size_t nboard_thread_object_fields; +extern const struct bile_object_field board_thread_object_fields[]; +extern const size_t nboard_thread_object_fields; void board_show(struct session *s, short id);