aboutsummaryrefslogtreecommitdiffstats
path: root/src/tag.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-08-29 09:38:33 +0200
committerEric Wong <normalperson@yhbt.net>2008-09-02 00:19:57 -0700
commitb24dbaef8dc73ccff85ae3948ff508c1cab4ede9 (patch)
treefa1a97e6b2a9fb663850385e9a6a59b1a048218b /src/tag.c
parent62f527a609d14890886580fe453a9219ae0a2bf7 (diff)
downloadmpd-b24dbaef8dc73ccff85ae3948ff508c1cab4ede9.tar.gz
mpd-b24dbaef8dc73ccff85ae3948ff508c1cab4ede9.tar.xz
mpd-b24dbaef8dc73ccff85ae3948ff508c1cab4ede9.zip
tag: converted tag_item.value to a char array
The value is stored in the same memory allocation as the tag_item struct; this saves memory because we do not store the value pointer anymore. Also remove the getTagItemString()/removeTagItemString() dummies.
Diffstat (limited to '')
-rw-r--r--src/tag.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/tag.c b/src/tag.c
index 311b49d50..2a4b27488 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -248,7 +248,6 @@ static void deleteItem(struct mpd_tag *tag, int idx)
assert(idx < tag->numOfItems);
tag->numOfItems--;
- removeTagItemString(tag->items[idx]->type, tag->items[idx]->value);
free(tag->items[idx]);
/* free(tag->items[idx].value); */
@@ -284,7 +283,6 @@ static void clearMpdTag(struct mpd_tag *tag)
int i;
for (i = 0; i < tag->numOfItems; i++) {
- removeTagItemString(tag->items[i]->type, tag->items[i]->value);
/* free(tag->items[i].value); */
free(tag->items[i]);
}
@@ -374,9 +372,10 @@ static void appendToTagItems(struct mpd_tag *tag, enum tag_type type,
tag->items = xrealloc(tag->items,
tag->numOfItems * sizeof(*tag->items));
- tag->items[i] = xmalloc(sizeof(*tag->items[i]));
+ len = strlen(duplicated);
+ tag->items[i] = xmalloc(sizeof(*tag->items[i]) + len);
tag->items[i]->type = type;
- tag->items[i]->value = getTagItemString(type, duplicated);
+ memcpy(tag->items[i]->value, duplicated, len + 1);
free(duplicated);
}