aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-08-29 09:38:54 +0200
committerEric Wong <normalperson@yhbt.net>2008-09-02 00:20:10 -0700
commitbbafa24ba65878780101191b9313e9e70208937e (patch)
treeb9efe30d23debb51fdd1d3afd3f1d5c52e406655 /src
parent318a284906f0e594f7c70c6fe72f234923fb6153 (diff)
downloadmpd-bbafa24ba65878780101191b9313e9e70208937e.tar.gz
mpd-bbafa24ba65878780101191b9313e9e70208937e.tar.xz
mpd-bbafa24ba65878780101191b9313e9e70208937e.zip
tag: converted macro fixUtf8() to an inline function
Since the inline function cannot modify its caller's variables (which is a good thing for code readability), the new string pointer is the return value. The resulting binary should be the same as with the macro.
Diffstat (limited to 'src')
-rw-r--r--src/tag.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/tag.c b/src/tag.c
index 8cc27b551..8b80bc308 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -347,14 +347,16 @@ int tag_equal(struct mpd_tag *tag1, struct mpd_tag *tag2)
return 1;
}
-#define fixUtf8(str) { \
- if(str && !validUtf8String(str)) { \
- char * temp; \
- DEBUG("not valid utf8 in tag: %s\n",str); \
- temp = latin1StrToUtf8Dup(str); \
- free(str); \
- str = temp; \
- } \
+static inline char *fix_utf8(char *str) {
+ char *temp;
+
+ if (str != NULL && validUtf8String(str))
+ return str;
+
+ DEBUG("not valid utf8 in tag: %s\n",str);
+ temp = latin1StrToUtf8Dup(str);
+ free(str);
+ return temp;
}
static void appendToTagItems(struct mpd_tag *tag, enum tag_type type,
@@ -366,7 +368,7 @@ static void appendToTagItems(struct mpd_tag *tag, enum tag_type type,
memcpy(duplicated, value, len);
duplicated[len] = '\0';
- fixUtf8(duplicated);
+ duplicated = fix_utf8(duplicated);
stripReturnChar(duplicated);
tag->numOfItems++;