aboutsummaryrefslogtreecommitdiffstats
path: root/src/output
diff options
context:
space:
mode:
authorJonathan Neuschäfer <j.neuschaefer@gmx.net>2011-07-25 11:17:33 +0200
committerJonathan Neuschäfer <j.neuschaefer@gmx.net>2011-07-25 11:23:22 +0200
commiteea726740bf222a92885b0f3c3c1255a5b04cd01 (patch)
tree1df79a7d58eea7dc92f0f0c027a1e048e86c1904 /src/output
parent0ea4c970d794d535ae6efb4d0ae2d3fe37980ae3 (diff)
downloadmpd-eea726740bf222a92885b0f3c3c1255a5b04cd01.tar.gz
mpd-eea726740bf222a92885b0f3c3c1255a5b04cd01.tar.xz
mpd-eea726740bf222a92885b0f3c3c1255a5b04cd01.zip
output/raop: rewrite remove_char_from_string
Diffstat (limited to '')
-rw-r--r--src/output/raop_output_plugin.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/output/raop_output_plugin.c b/src/output/raop_output_plugin.c
index b46633dfd..f3c32382a 100644
--- a/src/output/raop_output_plugin.c
+++ b/src/output/raop_output_plugin.c
@@ -182,21 +182,22 @@ kd_lookup(struct key_data *kd, const char *key)
* return the number of deleted characters
*/
static int
-remove_char_from_string(char *str, char rc)
+remove_char_from_string(char *str, char c)
{
- int i = 0, j = 0, len;
- int num = 0;
- len = strlen(str);
- while (i < len) {
- if (str[i] == rc) {
- for (j = i; j < len; j++) str[j] = str[j + 1];
- len--;
- num++;
- } else {
- i++;
- }
- }
- return num;
+ char *src, *dst;
+
+ /* skip all characters that don't need to be copied */
+ src = strchr(str, c);
+ if (!src)
+ return 0;
+
+ for (dst = src; *src; src++)
+ if (*src != c)
+ *(dst++) = *src;
+
+ *dst = '\0';
+
+ return src - dst;
}
#define SLEEP_MSEC(val) usleep(val*1000)