/* frees the whole piano handle structure * @param piano handle * @return nothing */ void PianoDestroy (PianoHandle_t *ph) { PianoDestroyUserInfo (&ph->user); PianoDestroyStations (ph->stations); /* destroy genre stations */ PianoGenreCategory_t *curGenreCat = ph->genreStations, *lastGenreCat; while (curGenreCat != NULL) { PianoDestroyGenres (curGenreCat->genres); free (curGenreCat->name); lastGenreCat = curGenreCat; curGenreCat = curGenreCat->next; free (lastGenreCat); } memset (ph, 0, sizeof (*ph)); }
/* frees the whole piano handle structure * @param piano handle * @return nothing */ void PianoDestroy (PianoHandle_t *ph) { PianoFree (ph->user.webAuthToken, 0); PianoFree (ph->user.authToken, 0); PianoFree (ph->user.listenerId, 0); PianoDestroyStations (ph->stations); /* destroy genre stations */ PianoGenreCategory_t *curGenreCat = ph->genreStations, *lastGenreCat; while (curGenreCat != NULL) { PianoDestroyGenres (curGenreCat->genres); PianoFree (curGenreCat->name, 0); lastGenreCat = curGenreCat; curGenreCat = curGenreCat->next; PianoFree (lastGenreCat, sizeof (*lastGenreCat)); } memset (ph, 0, sizeof (*ph)); }