annotate element struct with packing attributes to reduce entry size
This commit is contained in:
parent
08c7ef6bed
commit
63c35da66e
|
@ -119,21 +119,21 @@ enum store_entry_elem_flags {
|
||||||
* @note Order is important to avoid excessive structure packing overhead.
|
* @note Order is important to avoid excessive structure packing overhead.
|
||||||
*/
|
*/
|
||||||
struct store_entry_element {
|
struct store_entry_element {
|
||||||
uint32_t size; /**< size of entry element on disc */
|
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
uint8_t* data; /**< data allocated on heap */
|
uint8_t* data; /**< data allocated on heap */
|
||||||
uint8_t ref; /**< reference count */
|
uint8_t ref; /**< reference count */
|
||||||
} heap;
|
} __attribute__((__packed__)) heap;
|
||||||
struct {
|
struct {
|
||||||
uint8_t* data; /**< data is from an mmapping */
|
uint8_t* data; /**< data is from an mmapping */
|
||||||
uint8_t ref; /**< reference count */
|
uint8_t ref; /**< reference count */
|
||||||
} map;
|
} __attribute__((__packed__)) map;
|
||||||
struct {
|
struct {
|
||||||
uint16_t block; /**< small object data block */
|
uint16_t block; /**< small object data block */
|
||||||
} small;
|
} __attribute__((__packed__)) small;
|
||||||
} u;
|
} u ;
|
||||||
uint8_t flags; /* extension flags */
|
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);
|
entries_size = (1 << state->entry_bits) * sizeof(struct store_entry);
|
||||||
|
|
||||||
LOG(("Allocating %d bytes for max of %d entries",
|
LOG(("Allocating %d bytes for max of %d entries of %d length elements %d length",
|
||||||
entries_size, 1 << state->entry_bits));
|
entries_size, 1 << state->entry_bits,
|
||||||
|
sizeof(struct store_entry),
|
||||||
|
sizeof(struct store_entry_element)));
|
||||||
|
|
||||||
state->entries = calloc(1, entries_size);
|
state->entries = calloc(1, entries_size);
|
||||||
if (state->entries == NULL) {
|
if (state->entries == NULL) {
|
||||||
|
|
Loading…
Reference in New Issue