summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarsten Blees <karsten.blees@gmail.com>2013-12-07 20:56:32 +0100
committerJunio C Hamano <gitster@pobox.com>2014-02-24 15:26:46 -0800
commit0e5b77af2c0f6253025afbdb77aff38a02e30602 (patch)
treeb5ea498eb757c4bf63f819bd436349bc892ba90f
parent7b359ea6b3333a87fd3fa8b84913f2b75ed244ad (diff)
downloadgit-kb/fast-hashmap-pack-struct.tar.gz
hashmap.h: make sure map entries are tightly packedkb/fast-hashmap-pack-struct
Extending 'struct hashmap_entry' with an int-sized member shouldn't waste memory on 64-bit systems. This is already documented in api-hashmap.txt, but needs '__attribute__((__packed__))' to work. Reduces e.g. struct name_entry { struct hashmap_entry ent; int namelen; char *name; }; from 32 to 24 bytes. Signed-off-by: Karsten Blees <blees@dcon.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--hashmap.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/hashmap.h b/hashmap.h
index a816ad47b1..b64567bc17 100644
--- a/hashmap.h
+++ b/hashmap.h
@@ -15,7 +15,7 @@ extern unsigned int memihash(const void *buf, size_t len);
/* data structures */
-struct hashmap_entry {
+struct __attribute__((__packed__)) hashmap_entry {
struct hashmap_entry *next;
unsigned int hash;
};