jcs
/subtext
/amendments
/276
folder: constify fields
jcs made amendment 276 over 2 years ago
--- folder.c Mon Nov 7 12:04:11 2022
+++ folder.c Tue Nov 8 13:05:21 2022
@@ -32,7 +32,7 @@
#define FILE_VIEW_RETURN_LIST -2
#define FILE_VIEW_RETURN_FIND -3
-struct struct_field folder_fields[] = {
+const struct struct_field folder_fields[] = {
{ "Folder ID", CONFIG_TYPE_LONG,
offsetof(struct folder, id),
1, ULONG_MAX },
@@ -52,9 +52,9 @@ struct struct_field folder_fields[] = {
offsetof(struct folder, restricted_viewing),
0, 0 },
};
-size_t nfolder_fields = nitems(folder_fields);
+const size_t nfolder_fields = nitems(folder_fields);
-struct bile_object_field folder_object_fields[] = {
+const struct bile_object_field folder_object_fields[] = {
{ offsetof(struct folder, id),
member_size(struct folder, id), -1 },
{ offsetof(struct folder, name),
@@ -72,9 +72,9 @@ struct bile_object_field folder_object_fields[] = {
{ offsetof(struct folder, path),
member_size(struct folder, path), -1 },
};
-size_t nfolder_object_fields = nitems(folder_object_fields);
+const size_t nfolder_object_fields = nitems(folder_object_fields);
-struct bile_object_field folder_file_object_fields[] = {
+const struct bile_object_field folder_file_object_fields[] = {
{ offsetof(struct folder_file, id),
member_size(struct folder_file, id), -1 },
{ offsetof(struct folder_file, time),
@@ -94,7 +94,7 @@ struct bile_object_field folder_file_object_fields[] =
{ offsetof(struct folder_file, notes),
-1, offsetof(struct folder_file, notes_size) },
};
-size_t nfolder_file_object_fields = nitems(folder_file_object_fields);
+const size_t nfolder_file_object_fields = nitems(folder_file_object_fields);
unsigned long folder_upload(struct session *s, struct folder *folder,
char *initial_filename, char *initial_description);
--- folder.h Fri Jul 15 23:36:48 2022
+++ folder.h Tue Nov 8 13:04:50 2022
@@ -37,10 +37,10 @@ struct folder {
struct bile *bile;
};
-extern struct struct_field folder_fields[];
-extern size_t nfolder_fields;
-extern struct bile_object_field folder_object_fields[];
-extern size_t nfolder_object_fields;
+extern const struct struct_field folder_fields[];
+extern const size_t nfolder_fields;
+extern const struct bile_object_field folder_object_fields[];
+extern const size_t nfolder_object_fields;
struct folder_file {
unsigned long id;
@@ -55,8 +55,8 @@ struct folder_file {
size_t notes_size;
char *notes;
};
-extern struct bile_object_field folder_file_object_fields[];
-extern size_t nfolder_file_object_fields;
+extern const struct bile_object_field folder_file_object_fields[];
+extern const size_t nfolder_file_object_fields;
void folder_list(struct session *s);