summaryrefslogtreecommitdiff
path: root/content
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2014-11-23 01:25:14 +0000
committerVincent Sanders <vince@kyllikki.org>2014-11-23 01:25:14 +0000
commit63c35da66ed040df8c675ae9d86f4834e26980a3 (patch)
tree24a8201a4884b314a1fece57cd7ad974e94812eb /content
parent08c7ef6bed99a233aaf14c8e571f165075a55b90 (diff)
downloadnetsurf-63c35da66ed040df8c675ae9d86f4834e26980a3.tar.gz
netsurf-63c35da66ed040df8c675ae9d86f4834e26980a3.tar.bz2
annotate element struct with packing attributes to reduce entry size
Diffstat (limited to 'content')
-rw-r--r--content/fs_backing_store.c16
1 files changed, 9 insertions, 7 deletions
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) {