mirror of
https://gitlab.xiph.org/xiph/ezstream.git
synced 2024-11-03 04:17:18 -05:00
Add function to free a configuration in case of an error.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12548 0101bb08-14d6-0310-b084-bc0e0c8e3800
This commit is contained in:
parent
2874fca043
commit
99e0d7b8bf
@ -37,6 +37,8 @@
|
||||
static EZCONFIG ezConfig;
|
||||
static char *blankString = "";
|
||||
|
||||
void freeConfig(EZCONFIG *);
|
||||
|
||||
EZCONFIG *
|
||||
getEZConfig(void)
|
||||
{
|
||||
@ -81,6 +83,57 @@ getFormatDecoder(const char *match)
|
||||
return (blankString);
|
||||
}
|
||||
|
||||
void
|
||||
freeConfig(EZCONFIG *cfg)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if (cfg == NULL)
|
||||
return;
|
||||
|
||||
if (cfg->URL != NULL)
|
||||
xfree(cfg->URL);
|
||||
if (cfg->password != NULL)
|
||||
xfree(cfg->password);
|
||||
if (cfg->format != NULL)
|
||||
xfree(cfg->format);
|
||||
if (cfg->fileName != NULL)
|
||||
xfree(cfg->fileName);
|
||||
if (cfg->serverName != NULL)
|
||||
xfree(cfg->serverName);
|
||||
if (cfg->serverURL != NULL)
|
||||
xfree(cfg->serverURL);
|
||||
if (cfg->serverGenre != NULL)
|
||||
xfree(cfg->serverGenre);
|
||||
if (cfg->serverDescription != NULL)
|
||||
xfree(cfg->serverDescription);
|
||||
if (cfg->serverBitrate != NULL)
|
||||
xfree(cfg->serverBitrate);
|
||||
if (cfg->serverChannels != NULL)
|
||||
xfree(cfg->serverChannels);
|
||||
if (cfg->serverSamplerate != NULL)
|
||||
xfree(cfg->serverSamplerate);
|
||||
if (cfg->serverQuality != NULL)
|
||||
xfree(cfg->serverQuality);
|
||||
if (cfg->encoderDecoders != NULL) {
|
||||
for (i = 0; i < MAX_FORMAT_ENCDEC; i++) {
|
||||
if (cfg->encoderDecoders[i] != NULL) {
|
||||
if (cfg->encoderDecoders[i]->format != NULL)
|
||||
xfree(cfg->encoderDecoders[i]->format);
|
||||
if (cfg->encoderDecoders[i]->match != NULL)
|
||||
xfree(cfg->encoderDecoders[i]->match);
|
||||
if (cfg->encoderDecoders[i]->encoder != NULL)
|
||||
xfree(cfg->encoderDecoders[i]->encoder);
|
||||
if (cfg->encoderDecoders[i]->decoder != NULL)
|
||||
xfree(cfg->encoderDecoders[i]->decoder);
|
||||
xfree(cfg->encoderDecoders[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
memset(cfg, 0, sizeof(EZCONFIG));
|
||||
}
|
||||
|
||||
int parseConfig(const char *fileName)
|
||||
{
|
||||
xmlDocPtr doc;
|
||||
|
Loading…
Reference in New Issue
Block a user