summaryrefslogtreecommitdiff
path: root/src/tag
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-07 23:33:46 +0100
committerMax Kellermann <max@duempel.org>2014-01-07 23:35:18 +0100
commit27ca0db7a6143d2e479ff1ae52ec7c349ab1d4f2 (patch)
tree3f200069ab73baa09898fe1f242c6fd85396e2ba /src/tag
parent49f34fbf6861f10dbf9eb7549177888394926ff9 (diff)
util/Alloc: new library replacing GLib's g_malloc()
Diffstat (limited to 'src/tag')
-rw-r--r--src/tag/TagBuilder.cxx5
-rw-r--r--src/tag/TagConfig.cxx7
-rw-r--r--src/tag/TagPool.cxx1
-rw-r--r--src/tag/TagString.cxx15
4 files changed, 18 insertions, 10 deletions
diff --git a/src/tag/TagBuilder.cxx b/src/tag/TagBuilder.cxx
index 37aa08cee..3e6d2aeb8 100644
--- a/src/tag/TagBuilder.cxx
+++ b/src/tag/TagBuilder.cxx
@@ -24,10 +24,9 @@
#include "TagString.hxx"
#include "Tag.hxx"
-#include <glib.h>
-
#include <assert.h>
#include <string.h>
+#include <stdlib.h>
TagBuilder::TagBuilder(const Tag &other)
:time(other.time), has_playlist(other.has_playlist)
@@ -187,7 +186,7 @@ TagBuilder::AddItemInternal(TagType type, const char *value, size_t length)
auto i = tag_pool_get_item(type, value, length);
tag_pool_lock.unlock();
- g_free(p);
+ free(p);
items.push_back(i);
}
diff --git a/src/tag/TagConfig.cxx b/src/tag/TagConfig.cxx
index 0213ab4dc..5c81fa603 100644
--- a/src/tag/TagConfig.cxx
+++ b/src/tag/TagConfig.cxx
@@ -24,12 +24,15 @@
#include "ConfigGlobal.hxx"
#include "ConfigOption.hxx"
#include "system/FatalError.hxx"
+#include "util/Alloc.hxx"
#include "util/ASCII.hxx"
#include <glib.h>
#include <algorithm>
+#include <stdlib.h>
+
void
TagLoadConfig()
{
@@ -44,7 +47,7 @@ TagLoadConfig()
bool quit = false;
char *temp, *c, *s;
- temp = c = s = g_strdup(value);
+ temp = c = s = xstrdup(value);
do {
if (*s == ',' || *s == '\0') {
if (*s == '\0')
@@ -68,5 +71,5 @@ TagLoadConfig()
s++;
} while (!quit);
- g_free(temp);
+ free(temp);
}
diff --git a/src/tag/TagPool.cxx b/src/tag/TagPool.cxx
index 189dbdcc4..409edb662 100644
--- a/src/tag/TagPool.cxx
+++ b/src/tag/TagPool.cxx
@@ -25,6 +25,7 @@
#include <assert.h>
#include <string.h>
+#include <stdlib.h>
Mutex tag_pool_lock;
diff --git a/src/tag/TagString.cxx b/src/tag/TagString.cxx
index 3e8d8c1b0..9d2bd68ec 100644
--- a/src/tag/TagString.cxx
+++ b/src/tag/TagString.cxx
@@ -19,11 +19,13 @@
#include "config.h"
#include "TagString.hxx"
+#include "util/Alloc.hxx"
#include <glib.h>
#include <assert.h>
#include <string.h>
+#include <stdlib.h>
/**
* Replace invalid sequences with the question mark.
@@ -33,7 +35,7 @@ patch_utf8(const char *src, size_t length, const gchar *end)
{
/* duplicate the string, and replace invalid bytes in that
buffer */
- char *dest = g_strdup(src);
+ char *dest = xstrdup(src);
do {
dest[end - src] = '?';
@@ -58,9 +60,12 @@ fix_utf8(const char *str, size_t length)
/* no, it's not - try to import it from ISO-Latin-1 */
temp = g_convert(str, length, "utf-8", "iso-8859-1",
nullptr, &written, nullptr);
- if (temp != nullptr)
+ if (temp != nullptr) {
/* success! */
- return temp;
+ char *p = xstrdup(temp);
+ g_free(temp);
+ return p;
+ }
/* no, still broken - there's no medication, just patch
invalid sequences */
@@ -96,7 +101,7 @@ clear_non_printable(const char *p, size_t length)
if (first == nullptr)
return nullptr;
- dest = g_strndup(p, length);
+ dest = xstrndup(p, length);
for (size_t i = first - p; i < length; ++i)
if (char_is_non_printable(dest[i]))
@@ -120,7 +125,7 @@ FixTagString(const char *p, size_t length)
if (cleared == nullptr)
cleared = utf8;
else
- g_free(utf8);
+ free(utf8);
return cleared;
}