Skip to content

Commit e2b5038

Browse files
Eric Wonggitster
Eric Wong
authored andcommitted
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 <[email protected]> Signed-off-by: Eric Wong <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 404ab78 commit e2b5038

File tree

9 files changed

+11
-10
lines changed

9 files changed

+11
-10
lines changed

Diff for: attr.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static struct attr_hashmap g_attr_hashmap;
6262

6363
/* The container for objects stored in "struct attr_hashmap" */
6464
struct attr_hash_entry {
65-
struct hashmap_entry ent; /* must be the first member! */
65+
struct hashmap_entry ent;
6666
const char *key; /* the key; memory should be owned by value */
6767
size_t keylen; /* length of the key */
6868
void *value; /* the stored value */

Diff for: builtin/fetch.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ static int will_fetch(struct ref **head, const unsigned char *sha1)
251251
}
252252

253253
struct refname_hash_entry {
254-
struct hashmap_entry ent; /* must be the first member */
254+
struct hashmap_entry ent;
255255
struct object_id oid;
256256
int ignore;
257257
char refname[FLEX_ARRAY];

Diff for: hashmap.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
* struct hashmap map;
1515
* struct long2string {
16-
* struct hashmap_entry ent; // must be the first member!
16+
* struct hashmap_entry ent;
1717
* long key;
1818
* char value[FLEX_ARRAY]; // be careful with allocating on stack!
1919
* };
@@ -141,7 +141,7 @@ static inline unsigned int oidhash(const struct object_id *oid)
141141

142142
/*
143143
* 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.
145145
* Ideally it should be followed by an int-sized member to prevent unused
146146
* memory on 64-bit systems due to alignment.
147147
*/

Diff for: merge-recursive.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ struct merge_options {
5050
* in get_directory_renames() for details
5151
*/
5252
struct dir_rename_entry {
53-
struct hashmap_entry ent; /* must be the first member! */
53+
struct hashmap_entry ent;
5454
char *dir;
5555
unsigned non_unique_new_dir:1;
5656
struct strbuf new_dir;
5757
struct string_list possible_new_dirs;
5858
};
5959

6060
struct collision_entry {
61-
struct hashmap_entry ent; /* must be the first member! */
61+
struct hashmap_entry ent;
6262
char *target_file;
6363
struct string_list source_files;
6464
unsigned reported_already:1;

Diff for: ref-filter.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ static struct expand_data {
7979
} oi, oi_deref;
8080

8181
struct ref_to_worktree_entry {
82-
struct hashmap_entry ent; /* must be the first member! */
82+
struct hashmap_entry ent;
8383
struct worktree *wt; /* key is wt->head_ref */
8484
};
8585

Diff for: refs.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1772,7 +1772,7 @@ int resolve_gitlink_ref(const char *submodule, const char *refname,
17721772

17731773
struct ref_store_hash_entry
17741774
{
1775-
struct hashmap_entry ent; /* must be the first member! */
1775+
struct hashmap_entry ent;
17761776

17771777
struct ref_store *refs;
17781778

Diff for: remote.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ enum {
1414
};
1515

1616
struct remote {
17-
struct hashmap_entry ent; /* must be first */
17+
struct hashmap_entry ent;
1818

1919
const char *name;
2020
int origin, configured_in_repo;

Diff for: sub-process.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
/* Members should not be accessed directly. */
2626
struct subprocess_entry {
27-
struct hashmap_entry ent; /* must be the first member! */
27+
struct hashmap_entry ent;
2828
const char *cmd;
2929
struct child_process process;
3030
};

Diff for: t/helper/test-hashmap.c

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
struct test_entry
77
{
8+
int padding; /* hashmap entry no longer needs to be the first member */
89
struct hashmap_entry ent;
910
/* key and value as two \0-terminated strings */
1011
char key[FLEX_ARRAY];

0 commit comments

Comments
 (0)