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:
Eric Wong 2008-10-13 09:40:14 +02:00 committed by Max Kellermann
parent c641aabe33
commit 8867bd554c
2 changed files with 4 additions and 2 deletions

View File

@ -44,7 +44,7 @@ extern const char *mpdTagItemKeys[];
struct tag_item {
enum tag_type type;
char value[1];
char value[sizeof(long)];
} mpd_packed;
struct tag {

View File

@ -69,7 +69,9 @@ static struct slot *slot_alloc(struct slot *next,
enum tag_type type,
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->ref = 1;
slot->item.type = type;