aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-10-06 18:48:45 +0200
committerEric Wong <normalperson@yhbt.net>2008-10-11 19:21:46 -0700
commitb843ae1dde619605a318002b2c2326a9cce380f0 (patch)
tree741d64f8071a2621118da41e52e27b27c0f12522
parentc95334b2095e57e900e2c09e858b86f78a5bdb06 (diff)
downloadmpd-b843ae1dde619605a318002b2c2326a9cce380f0.tar.gz
mpd-b843ae1dde619605a318002b2c2326a9cce380f0.tar.xz
mpd-b843ae1dde619605a318002b2c2326a9cce380f0.zip
song: don't make the struct packed
The "packed" attribute may have negative side effects on performance. Remove the "packed" attribute, and increase the size of "song.url" to a multiple of the machine word size.
-rw-r--r--src/song.c2
-rw-r--r--src/song.h2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/song.c b/src/song.c
index c9301386d..03f65dd0d 100644
--- a/src/song.c
+++ b/src/song.c
@@ -37,7 +37,7 @@ static Song * song_alloc(const char *url, Directory *parent)
assert(url);
urllen = strlen(url);
assert(urllen);
- song = xmalloc(sizeof(Song) + urllen);
+ song = xmalloc(sizeof(*song) - sizeof(song->url) + urllen + 1);
song->tag = NULL;
memcpy(song->url, url, urllen + 1);
diff --git a/src/song.h b/src/song.h
index 9aa9efa94..58506280b 100644
--- a/src/song.h
+++ b/src/song.h
@@ -37,7 +37,7 @@ typedef struct _Song {
struct mpd_tag *tag;
struct _Directory *parentDir;
time_t mtime;
- char url[1];
+ char url[sizeof(size_t)];
} mpd_packed Song;
Song *newSong(const char *url, struct _Directory *parentDir);