aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2008-10-11 20:15:43 -0700
committerEric Wong <normalperson@yhbt.net>2008-10-12 05:27:32 -0700
commitaed02f0fedf56f6684cb98e33d0c616d4f80e81f (patch)
tree7fb8479a9de6be8cc0d0e71b1ff8427a7b8cd2c5
parent442b041d3f00e2edec209dfafecb50f49f03402c (diff)
downloadmpd-aed02f0fedf56f6684cb98e33d0c616d4f80e81f.tar.gz
mpd-aed02f0fedf56f6684cb98e33d0c616d4f80e81f.tar.xz
mpd-aed02f0fedf56f6684cb98e33d0c616d4f80e81f.zip
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.
-rw-r--r--src/tag.h2
-rw-r--r--src/tag_pool.c4
2 files changed, 4 insertions, 2 deletions
diff --git a/src/tag.h b/src/tag.h
index 744b82e83..58df5b3d1 100644
--- a/src/tag.h
+++ b/src/tag.h
@@ -42,7 +42,7 @@ extern const char *mpdTagItemKeys[];
struct tag_item {
enum tag_type type;
- char value[1];
+ char value[mpd_sizeof_str_flex_array];
} mpd_packed;
struct mpd_tag {
diff --git a/src/tag_pool.c b/src/tag_pool.c
index d227a2988..1d92502cc 100644
--- a/src/tag_pool.c
+++ b/src/tag_pool.c
@@ -67,7 +67,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;