From 63c35da66ed040df8c675ae9d86f4834e26980a3 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sun, 23 Nov 2014 01:25:14 +0000 Subject: annotate element struct with packing attributes to reduce entry size --- content/fs_backing_store.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'content') diff --git a/content/fs_backing_store.c b/content/fs_backing_store.c index 1c103e7e1..6686d77c9 100644 --- a/content/fs_backing_store.c +++ b/content/fs_backing_store.c @@ -119,21 +119,21 @@ enum store_entry_elem_flags { * @note Order is important to avoid excessive structure packing overhead. */ struct store_entry_element { - uint32_t size; /**< size of entry element on disc */ union { struct { uint8_t* data; /**< data allocated on heap */ uint8_t ref; /**< reference count */ - } heap; + } __attribute__((__packed__)) heap; struct { uint8_t* data; /**< data is from an mmapping */ uint8_t ref; /**< reference count */ - } map; + } __attribute__((__packed__)) map; struct { uint16_t block; /**< small object data block */ - } small; - } u; + } __attribute__((__packed__)) small; + } u ; uint8_t flags; /* extension flags */ + uint32_t size; /**< size of entry element on disc */ }; /** @@ -923,8 +923,10 @@ read_entries(struct store_state *state) entries_size = (1 << state->entry_bits) * sizeof(struct store_entry); - LOG(("Allocating %d bytes for max of %d entries", - entries_size, 1 << state->entry_bits)); + LOG(("Allocating %d bytes for max of %d entries of %d length elements %d length", + entries_size, 1 << state->entry_bits, + sizeof(struct store_entry), + sizeof(struct store_entry_element))); state->entries = calloc(1, entries_size); if (state->entries == NULL) { -- cgit v1.2.3