summaryrefslogtreecommitdiff
path: root/libpiano/src
diff options
context:
space:
mode:
authorLars-Dominik Braun <PromyLOPh@lavabit.com>2009-08-06 14:57:37 +0200
committerLars-Dominik Braun <PromyLOPh@lavabit.com>2009-08-06 14:57:37 +0200
commitc43af87ffb13775ea71795baa595e4633f9fd529 (patch)
treeedd98a4c204d8fdd3482ae68b0943435754f149e /libpiano/src
parent3d7998a44299c69e7d721c4c5a20ddc32cec562b (diff)
downloadpianobar-windows-c43af87ffb13775ea71795baa595e4633f9fd529.tar.gz
pianobar-windows-c43af87ffb13775ea71795baa595e4633f9fd529.tar.bz2
pianobar-windows-c43af87ffb13775ea71795baa595e4633f9fd529.zip
piano: Don't alloc memory for tmp errorstrings
Diffstat (limited to 'libpiano/src')
-rw-r--r--libpiano/src/xml.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/libpiano/src/xml.c b/libpiano/src/xml.c
index 463caa7..c8497be 100644
--- a/libpiano/src/xml.c
+++ b/libpiano/src/xml.c
@@ -45,7 +45,7 @@ static void PianoXmlIsFaultCb (const char *key, const ezxml_t value,
void *data) {
PianoReturn_t *ret = data;
char *valueStr = PianoXmlGetNodeText (value);
- char *matchStart, *matchEnd, *matchStr;
+ char *matchStart, *matchEnd;
if (strcmp ("faultString", key) == 0) {
*ret = PIANO_RET_ERR;
@@ -56,36 +56,34 @@ static void PianoXmlIsFaultCb (const char *key, const ezxml_t value,
if ((matchStart = strchr (valueStr, '|')) != NULL) {
if ((matchStart = strchr (matchStart+1, '|')) != NULL) {
if ((matchEnd = strchr (matchStart+1, '|')) != NULL) {
- matchStr = calloc (matchEnd - (matchStart+1)+1,
- sizeof (*matchStr));
- memcpy (matchStr, matchStart+1, matchEnd -
- (matchStart+1));
+ /* changes text in xml node, but we don't care... */
+ *matchEnd = '\0';
+ ++matchStart;
/* translate to our error message system */
- if (strcmp ("AUTH_INVALID_TOKEN", matchStr) == 0) {
+ if (strcmp ("AUTH_INVALID_TOKEN", matchStart) == 0) {
*ret = PIANO_RET_AUTH_TOKEN_INVALID;
} else if (strcmp ("AUTH_INVALID_USERNAME_PASSWORD",
- matchStr) == 0) {
+ matchStart) == 0) {
*ret = PIANO_RET_AUTH_USER_PASSWORD_INVALID;
} else if (strcmp ("LISTENER_NOT_AUTHORIZED",
- matchStr) == 0) {
+ matchStart) == 0) {
*ret = PIANO_RET_NOT_AUTHORIZED;
} else if (strcmp ("INCOMPATIBLE_VERSION",
- matchStr) == 0) {
+ matchStart) == 0) {
*ret = PIANO_RET_PROTOCOL_INCOMPATIBLE;
- } else if (strcmp ("READONLY_MODE", matchStr) == 0) {
+ } else if (strcmp ("READONLY_MODE", matchStart) == 0) {
*ret = PIANO_RET_READONLY_MODE;
} else if (strcmp ("STATION_CODE_INVALID",
- matchStr) == 0) {
+ matchStart) == 0) {
*ret = PIANO_RET_STATION_CODE_INVALID;
} else if (strcmp ("STATION_DOES_NOT_EXIST",
- matchStr) == 0) {
+ matchStart) == 0) {
*ret = PIANO_RET_STATION_NONEXISTENT;
} else {
*ret = PIANO_RET_ERR;
printf (PACKAGE ": Unknown error %s in %s\n",
- matchStr, valueStr);
+ matchStart, valueStr);
}
- PianoFree (matchStr, 0);
}
}
}