hashmap_entry: remove first member requirement from docs

Comments stating that "struct hashmap_entry" must be the first member in a struct are no longer valid. Suggested-by: Phillip Wood <phillip.wood123@gmail.com> Signed-off-by: Eric Wong <e@80x24.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Eric Wong committed Oct 6, 2019 at 23:30 UTC e2b5038d8793a1d1f92b62dab82acc0d6b7dbcb7
9 files changed +11 -10
attr.c
+1 -1
@@ -62,7 +62,7 @@ static struct attr_hashmap g_attr_hashmap;
62
63 /* The container for objects stored in "struct attr_hashmap" */
64 struct attr_hash_entry {
65 - struct hashmap_entry ent; /* must be the first member! */
65 + struct hashmap_entry ent;
66 const char *key; /* the key; memory should be owned by value */
67 size_t keylen; /* length of the key */
68 void *value; /* the stored value */
builtin/fetch.c
+1 -1
@@ -251,7 +251,7 @@ static int will_fetch(struct ref **head, const unsigned char *sha1)
251 }
252
253 struct refname_hash_entry {
254 - struct hashmap_entry ent; /* must be the first member */
254 + struct hashmap_entry ent;
255 struct object_id oid;
256 int ignore;
257 char refname[FLEX_ARRAY];
hashmap.h
+2 -2
@@ -13,7 +13,7 @@
13 *
14 * struct hashmap map;
15 * struct long2string {
16 - * struct hashmap_entry ent; // must be the first member!
16 + * struct hashmap_entry ent;
17 * long key;
18 * char value[FLEX_ARRAY]; // be careful with allocating on stack!
19 * };
@@ -141,7 +141,7 @@ static inline unsigned int oidhash(const struct object_id *oid)
141
142 /*
143 * struct hashmap_entry is an opaque structure representing an entry in the
144 - * hash table, which must be used as first member of user data structures.
144 + * hash table.
145 * Ideally it should be followed by an int-sized member to prevent unused
146 * memory on 64-bit systems due to alignment.
147 */
merge-recursive.h
+2 -2
@@ -50,7 +50,7 @@ struct merge_options {
50 * in get_directory_renames() for details
51 */
52 struct dir_rename_entry {
53 - struct hashmap_entry ent; /* must be the first member! */
53 + struct hashmap_entry ent;
54 char *dir;
55 unsigned non_unique_new_dir:1;
56 struct strbuf new_dir;
@@ -58,7 +58,7 @@ struct dir_rename_entry {
58 };
59
60 struct collision_entry {
61 - struct hashmap_entry ent; /* must be the first member! */
61 + struct hashmap_entry ent;
62 char *target_file;
63 struct string_list source_files;
64 unsigned reported_already:1;
ref-filter.c
+1 -1
@@ -79,7 +79,7 @@ static struct expand_data {
79 } oi, oi_deref;
80
81 struct ref_to_worktree_entry {
82 - struct hashmap_entry ent; /* must be the first member! */
82 + struct hashmap_entry ent;
83 struct worktree *wt; /* key is wt->head_ref */
84 };
85
refs.c
+1 -1
@@ -1772,7 +1772,7 @@ int resolve_gitlink_ref(const char *submodule, const char *refname,
1772
1773 struct ref_store_hash_entry
1774 {
1775 - struct hashmap_entry ent; /* must be the first member! */
1775 + struct hashmap_entry ent;
1776
1777 struct ref_store *refs;
1778
remote.h
+1 -1
@@ -14,7 +14,7 @@ enum {
14 };
15
16 struct remote {
17 - struct hashmap_entry ent; /* must be first */
17 + struct hashmap_entry ent;
18
19 const char *name;
20 int origin, configured_in_repo;
sub-process.h
+1 -1
@@ -24,7 +24,7 @@
24
25 /* Members should not be accessed directly. */
26 struct subprocess_entry {
27 - struct hashmap_entry ent; /* must be the first member! */
27 + struct hashmap_entry ent;
28 const char *cmd;
29 struct child_process process;
30 };
t/helper/test-hashmap.c
+1
@@ -5,6 +5,7 @@
5
6 struct test_entry
7 {
8 + int padding; /* hashmap entry no longer needs to be the first member */
9 struct hashmap_entry ent;
10 /* key and value as two \0-terminated strings */
11 char key[FLEX_ARRAY];