aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2010-09-23 08:49:21 +0200
committerMax Kellermann <max@duempel.org>2010-09-23 08:49:21 +0200
commit635cfbae131b323b62ca50c6bffb0b801b57aafe (patch)
tree6a587c6b95ea79d64694f08efa74c86304f91639
parent922e51e8a94de09ceec37bc6d26a0802de2e75d7 (diff)
downloadmpd-635cfbae131b323b62ca50c6bffb0b801b57aafe.tar.gz
mpd-635cfbae131b323b62ca50c6bffb0b801b57aafe.tar.xz
mpd-635cfbae131b323b62ca50c6bffb0b801b57aafe.zip
decoder_control: use g_free() to manage mixramp allocations
Be consistent with the rest of MPD, and don't use the non-portable header "malloc.h".
-rw-r--r--src/decoder/flac_metadata.c7
-rw-r--r--src/decoder/mad_decoder_plugin.c4
-rw-r--r--src/decoder_control.c19
3 files changed, 10 insertions, 20 deletions
diff --git a/src/decoder/flac_metadata.c b/src/decoder/flac_metadata.c
index 68d15f6d4..f2f2f954d 100644
--- a/src/decoder/flac_metadata.c
+++ b/src/decoder/flac_metadata.c
@@ -87,7 +87,7 @@ flac_find_string_comment(const FLAC__StreamMetadata *block,
int offset;
size_t pos;
int len;
- unsigned char tmp, *p;
+ const unsigned char *p;
*str = NULL;
offset = FLAC__metadata_object_vorbiscomment_find_entry_from(block, 0,
@@ -101,10 +101,7 @@ flac_find_string_comment(const FLAC__StreamMetadata *block,
return false;
p = &block->data.vorbis_comment.comments[offset].entry[pos];
- tmp = p[len];
- p[len] = '\0';
- *str = strdup((char *)p);
- p[len] = tmp;
+ *str = g_strndup((const char *)p, len);
return true;
}
diff --git a/src/decoder/mad_decoder_plugin.c b/src/decoder/mad_decoder_plugin.c
index 5aa09b336..a11d1b020 100644
--- a/src/decoder/mad_decoder_plugin.c
+++ b/src/decoder/mad_decoder_plugin.c
@@ -285,10 +285,10 @@ parse_id3_mixramp(char **mixramp_start, char **mixramp_end,
(&frame->fields[2]));
if (g_ascii_strcasecmp(key, "mixramp_start") == 0) {
- *mixramp_start = strdup(value);
+ *mixramp_start = g_strdup(value);
found = true;
} else if (g_ascii_strcasecmp(key, "mixramp_end") == 0) {
- *mixramp_end = strdup(value);
+ *mixramp_end = g_strdup(value);
found = true;
}
diff --git a/src/decoder_control.c b/src/decoder_control.c
index 9a1d9abfb..224abbf31 100644
--- a/src/decoder_control.c
+++ b/src/decoder_control.c
@@ -22,7 +22,6 @@
#include "player_control.h"
#include <assert.h>
-#include <malloc.h>
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "decoder_control"
@@ -50,12 +49,9 @@ dc_deinit(struct decoder_control *dc)
{
g_cond_free(dc->cond);
g_mutex_free(dc->mutex);
- if (dc->mixramp_start)
- free(dc->mixramp_start);
- if (dc->mixramp_end)
- free(dc->mixramp_end);
- if (dc->mixramp_prev_end)
- free(dc->mixramp_prev_end);
+ g_free(dc->mixramp_start);
+ g_free(dc->mixramp_end);
+ g_free(dc->mixramp_prev_end);
dc->mixramp_start = NULL;
dc->mixramp_end = NULL;
dc->mixramp_prev_end = NULL;
@@ -172,8 +168,7 @@ dc_mixramp_start(struct decoder_control *dc, char *mixramp_start)
{
assert(dc != NULL);
- if (dc->mixramp_start)
- free(dc->mixramp_start);
+ g_free(dc->mixramp_start);
dc->mixramp_start = mixramp_start;
g_debug("mixramp_start = %s", mixramp_start ? mixramp_start : "NULL");
}
@@ -183,8 +178,7 @@ dc_mixramp_end(struct decoder_control *dc, char *mixramp_end)
{
assert(dc != NULL);
- if (dc->mixramp_end)
- free(dc->mixramp_end);
+ g_free(dc->mixramp_end);
dc->mixramp_end = mixramp_end;
g_debug("mixramp_end = %s", mixramp_end ? mixramp_end : "NULL");
}
@@ -194,8 +188,7 @@ dc_mixramp_prev_end(struct decoder_control *dc, char *mixramp_prev_end)
{
assert(dc != NULL);
- if (dc->mixramp_prev_end)
- free(dc->mixramp_prev_end);
+ g_free(dc->mixramp_prev_end);
dc->mixramp_prev_end = mixramp_prev_end;
g_debug("mixramp_prev_end = %s", mixramp_prev_end ? mixramp_prev_end : "NULL");
}