summaryrefslogtreecommitdiff
path: root/libpiano/src/xml.c
diff options
context:
space:
mode:
authorLars-Dominik Braun <PromyLOPh@gmail.com>2008-08-08 19:37:31 +0200
committerLars-Dominik Braun <PromyLOPh@gmail.com>2008-08-08 19:37:31 +0200
commitb55cf2b0641d67f9832b14285af741ef0ed9d8bf (patch)
treecf3596f231dd0a27892fc138060062e70aeb1e79 /libpiano/src/xml.c
parente1cb484fe66410e45363f29b167fedf19f236ded (diff)
downloadpianobar-b55cf2b0641d67f9832b14285af741ef0ed9d8bf.tar.gz
pianobar-b55cf2b0641d67f9832b14285af741ef0ed9d8bf.tar.bz2
pianobar-b55cf2b0641d67f9832b14285af741ef0ed9d8bf.zip
Several code optimizations
Diffstat (limited to 'libpiano/src/xml.c')
-rw-r--r--libpiano/src/xml.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/libpiano/src/xml.c b/libpiano/src/xml.c
index 30f4c2e..c0d388f 100644
--- a/libpiano/src/xml.c
+++ b/libpiano/src/xml.c
@@ -617,7 +617,8 @@ char *PianoXmlEncodeString (const char *s) {
char *replacements[] = {"&&amp;", "'&apos;", "\"&quot;", "<&lt;",
">&gt;", NULL};
char **r;
- char *sOut = calloc (strlen (s) * 5 + 1, sizeof (*sOut));
+ char *sOut = calloc (strlen (s) * 5 + 1, sizeof (*sOut)),
+ *sOutCurr = sOut;
char found;
while (*s != '\0') {
@@ -626,13 +627,15 @@ char *PianoXmlEncodeString (const char *s) {
while (*r != NULL) {
if (*s == *r[0]) {
found = 1;
- strcat (sOut, (*r) + 1);
+ strcat (sOutCurr, (*r) + 1);
+ sOutCurr += strlen ((*r) + 1);
break;
}
r++;
}
if (!found) {
- strncat (sOut, s, 1);
+ *sOutCurr = *s;
+ sOutCurr++;
}
s++;
}