tag_item: avoid wasting space when struct is unpackable
Not all compilers support struct packing, and those that don't shouldn't be punished for it.
This commit is contained in:
parent
c641aabe33
commit
8867bd554c
@ -44,7 +44,7 @@ extern const char *mpdTagItemKeys[];
|
|||||||
|
|
||||||
struct tag_item {
|
struct tag_item {
|
||||||
enum tag_type type;
|
enum tag_type type;
|
||||||
char value[1];
|
char value[sizeof(long)];
|
||||||
} mpd_packed;
|
} mpd_packed;
|
||||||
|
|
||||||
struct tag {
|
struct tag {
|
||||||
|
@ -69,7 +69,9 @@ static struct slot *slot_alloc(struct slot *next,
|
|||||||
enum tag_type type,
|
enum tag_type type,
|
||||||
const char *value, int length)
|
const char *value, int length)
|
||||||
{
|
{
|
||||||
struct slot *slot = xmalloc(sizeof(*slot) + length);
|
struct slot *slot;
|
||||||
|
|
||||||
|
slot = xmalloc(sizeof(*slot) - sizeof(slot->item.value) + length + 1);
|
||||||
slot->next = next;
|
slot->next = next;
|
||||||
slot->ref = 1;
|
slot->ref = 1;
|
||||||
slot->item.type = type;
|
slot->item.type = type;
|
||||||
|
Loading…
Reference in New Issue
Block a user