summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars-Dominik Braun <PromyLOPh@gmail.com>2008-06-12 16:06:56 +0200
committerLars-Dominik Braun <PromyLOPh@gmail.com>2008-06-12 16:06:56 +0200
commit8fe2fdd58acebf96c9fdacb4d13d63ff50a1f898 (patch)
tree46b149f362b72877b7e25d1959ae1a73668a3590
parentaff2ce1e5755f87293135ebf9f3995313c05cec9 (diff)
downloadpianobar-windows-8fe2fdd58acebf96c9fdacb4d13d63ff50a1f898.tar.gz
pianobar-windows-8fe2fdd58acebf96c9fdacb4d13d63ff50a1f898.tar.bz2
pianobar-windows-8fe2fdd58acebf96c9fdacb4d13d63ff50a1f898.zip
lib: Delete station pointer when deleting station
-rw-r--r--libpiano/main.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/libpiano/main.c b/libpiano/main.c
index 8ec19bb..17bef4b 100644
--- a/libpiano/main.c
+++ b/libpiano/main.c
@@ -384,7 +384,25 @@ PianoReturn_t PianoDeleteStation (PianoHandle_t *ph, PianoStation_t *station) {
PianoHttpPost (ph->curlHandle, url, requestStr, &retStr);
ret = PianoXmlParseSimple (retStr);
- /* FIXME would be our job to delete station from global station list... */
+ if (ret == PIANO_RET_OK) {
+ /* delete station from local station list */
+ PianoStation_t *curStation = ph->stations, *lastStation = NULL;
+ while (curStation != NULL) {
+ if (curStation == station) {
+ printf ("deleting station\n");
+ if (lastStation != NULL) {
+ lastStation->next = curStation->next;
+ } else {
+ /* first station in list */
+ ph->stations = curStation->next;
+ }
+ PianoDestroyStation (curStation);
+ free (curStation);
+ }
+ lastStation = curStation;
+ curStation = curStation->next;
+ }
+ }
free (requestStr);
free (retStr);