diff options
author | Max Kellermann <max@duempel.org> | 2008-08-29 09:38:54 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-08-29 09:38:54 +0200 |
commit | f99fe808117fb29fc8dfba8c2eb1b18472aa6faa (patch) | |
tree | d131bffc0f6b7e2406494c5d270234f4b269787d /src/tag.c | |
parent | c855415c733d712aa0f129fbfdef2af11e289234 (diff) | |
download | mpd-f99fe808117fb29fc8dfba8c2eb1b18472aa6faa.tar.gz mpd-f99fe808117fb29fc8dfba8c2eb1b18472aa6faa.tar.xz mpd-f99fe808117fb29fc8dfba8c2eb1b18472aa6faa.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/tag.c')
-rw-r--r-- | src/tag.c | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -347,14 +347,16 @@ int tag_equal(struct tag *tag1, struct 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 tag *tag, enum tag_type type, @@ -366,7 +368,7 @@ static void appendToTagItems(struct tag *tag, enum tag_type type, memcpy(duplicated, value, len); duplicated[len] = '\0'; - fixUtf8(duplicated); + duplicated = fix_utf8(duplicated); stripReturnChar(duplicated); tag->numOfItems++; |