[xiph-commits] r12548 - trunk/ezstream/src
moritz at svn.xiph.org
moritz at svn.xiph.org
Sat Feb 24 15:05:52 PST 2007
Author: moritz
Date: 2007-02-24 15:05:51 -0800 (Sat, 24 Feb 2007)
New Revision: 12548
Modified:
trunk/ezstream/src/configfile.c
Log:
Add function to free a configuration in case of an error.
Modified: trunk/ezstream/src/configfile.c
===================================================================
--- trunk/ezstream/src/configfile.c 2007-02-24 23:03:51 UTC (rev 12547)
+++ trunk/ezstream/src/configfile.c 2007-02-24 23:05:51 UTC (rev 12548)
@@ -37,6 +37,8 @@
static EZCONFIG ezConfig;
static char *blankString = "";
+void freeConfig(EZCONFIG *);
+
EZCONFIG *
getEZConfig(void)
{
@@ -81,6 +83,57 @@
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;
More information about the commits
mailing list