summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-10-06 23:30:43 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-10-07 01:20:12 (GMT)
commite2b5038d8793a1d1f92b62dab82acc0d6b7dbcb7 (patch)
tree976db498f6351b16a1b93574315efdb55d0a810d
parent404ab78e39fc74c4eb604b6003642ed264f687a6 (diff)
downloadgit-e2b5038d8793a1d1f92b62dab82acc0d6b7dbcb7.zip
git-e2b5038d8793a1d1f92b62dab82acc0d6b7dbcb7.tar.gz
git-e2b5038d8793a1d1f92b62dab82acc0d6b7dbcb7.tar.bz2
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>
-rw-r--r--attr.c2
-rw-r--r--builtin/fetch.c2
-rw-r--r--hashmap.h4
-rw-r--r--merge-recursive.h4
-rw-r--r--ref-filter.c2
-rw-r--r--refs.c2
-rw-r--r--remote.h2
-rw-r--r--sub-process.h2
-rw-r--r--t/helper/test-hashmap.c1
9 files changed, 11 insertions, 10 deletions
diff --git a/attr.c b/attr.c
index 15f0efd..e5c951d 100644
--- a/attr.c
+++ b/attr.c
@@ -62,7 +62,7 @@ static struct attr_hashmap g_attr_hashmap;
/* The container for objects stored in "struct attr_hashmap" */
struct attr_hash_entry {
- struct hashmap_entry ent; /* must be the first member! */
+ struct hashmap_entry ent;
const char *key; /* the key; memory should be owned by value */
size_t keylen; /* length of the key */
void *value; /* the stored value */
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 09f7170..a3154a4 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -251,7 +251,7 @@ static int will_fetch(struct ref **head, const unsigned char *sha1)
}
struct refname_hash_entry {
- struct hashmap_entry ent; /* must be the first member */
+ struct hashmap_entry ent;
struct object_id oid;
int ignore;
char refname[FLEX_ARRAY];
diff --git a/hashmap.h b/hashmap.h
index bf4a059..bd27015 100644
--- a/hashmap.h
+++ b/hashmap.h
@@ -13,7 +13,7 @@
*
* struct hashmap map;
* struct long2string {
- * struct hashmap_entry ent; // must be the first member!
+ * struct hashmap_entry ent;
* long key;
* char value[FLEX_ARRAY]; // be careful with allocating on stack!
* };
@@ -141,7 +141,7 @@ static inline unsigned int oidhash(const struct object_id *oid)
/*
* struct hashmap_entry is an opaque structure representing an entry in the
- * hash table, which must be used as first member of user data structures.
+ * hash table.
* Ideally it should be followed by an int-sized member to prevent unused
* memory on 64-bit systems due to alignment.
*/
diff --git a/merge-recursive.h b/merge-recursive.h
index c2b7bb6..daa7425 100644
--- a/merge-recursive.h
+++ b/merge-recursive.h
@@ -50,7 +50,7 @@ struct merge_options {
* in get_directory_renames() for details
*/
struct dir_rename_entry {
- struct hashmap_entry ent; /* must be the first member! */
+ struct hashmap_entry ent;
char *dir;
unsigned non_unique_new_dir:1;
struct strbuf new_dir;
@@ -58,7 +58,7 @@ struct dir_rename_entry {
};
struct collision_entry {
- struct hashmap_entry ent; /* must be the first member! */
+ struct hashmap_entry ent;
char *target_file;
struct string_list source_files;
unsigned reported_already:1;
diff --git a/ref-filter.c b/ref-filter.c
index 0950b78..5c10a34 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -79,7 +79,7 @@ static struct expand_data {
} oi, oi_deref;
struct ref_to_worktree_entry {
- struct hashmap_entry ent; /* must be the first member! */
+ struct hashmap_entry ent;
struct worktree *wt; /* key is wt->head_ref */
};
diff --git a/refs.c b/refs.c
index 2d3eb40..1ab0bb5 100644
--- a/refs.c
+++ b/refs.c
@@ -1772,7 +1772,7 @@ int resolve_gitlink_ref(const char *submodule, const char *refname,
struct ref_store_hash_entry
{
- struct hashmap_entry ent; /* must be the first member! */
+ struct hashmap_entry ent;
struct ref_store *refs;
diff --git a/remote.h b/remote.h
index 83e8856..0e1d2b2 100644
--- a/remote.h
+++ b/remote.h
@@ -14,7 +14,7 @@ enum {
};
struct remote {
- struct hashmap_entry ent; /* must be first */
+ struct hashmap_entry ent;
const char *name;
int origin, configured_in_repo;
diff --git a/sub-process.h b/sub-process.h
index 0d12708..e85f21f 100644
--- a/sub-process.h
+++ b/sub-process.h
@@ -24,7 +24,7 @@
/* Members should not be accessed directly. */
struct subprocess_entry {
- struct hashmap_entry ent; /* must be the first member! */
+ struct hashmap_entry ent;
const char *cmd;
struct child_process process;
};
diff --git a/t/helper/test-hashmap.c b/t/helper/test-hashmap.c
index cc577c8..f387062 100644
--- a/t/helper/test-hashmap.c
+++ b/t/helper/test-hashmap.c
@@ -5,6 +5,7 @@
struct test_entry
{
+ int padding; /* hashmap entry no longer needs to be the first member */
struct hashmap_entry ent;
/* key and value as two \0-terminated strings */
char key[FLEX_ARRAY];