git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Avoid padding in structs index_state, packed_git

From
DPDilyan Palauzov <dilyan.palauzov@aegee.org>
Date
Aug 18, 2015, 10:55 UTC
Message-ID
<55D30F2F.4070907@aegee.org>

On 64 bit linux, sizeof (struct index_state) = 160 and sizeof (struct packed_git) = 104. This change shrinks the structs with 8bytes (as it avoids padding)

Signed-off-by: Дилян Палаузов <git-dpa@aegee.org>
---
diff --git a/cache.h b/cache.h
index 6bb7119..e00908b 100644
--- a/cache.h
+++ b/cache.h
@@ -310,11 +310,11 @@ struct index_state {
         struct cache_tree *cache_tree;
         struct split_index *split_index;
         struct cache_time timestamp;
-       unsigned name_hash_initialized : 1,
-                initialized : 1;
         struct hashmap name_hash;
         struct hashmap dir_hash;
         unsigned char sha1[20];
+       unsigned name_hash_initialized : 1,
+                initialized : 1;
         struct untracked_cache *untracked;
  };

@@ -1192,8 +1192,8 @@ extern struct packed_git {
         uint32_t num_objects;
         uint32_t num_bad_objects;
         unsigned char *bad_object_sha1;
-       int index_version;
         time_t mtime;
+       int index_version;
         int pack_fd;
         unsigned pack_local:1,
                  pack_keep:1,
Message 1 of 1 in “Avoid padding in structs index_state, packed_git”
  1. Dilyan PalauzovAug 18, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.