A simple .ini file interface.
Dependents: Smart-WiFly-WebServer SignalGenerator WattEye X10Svr
Diff: IniManager.cpp
- Revision:
- 11:738604f18088
- Parent:
- 10:57b93035ad82
- Child:
- 12:6cf929bde139
--- a/IniManager.cpp Fri Jul 03 17:51:24 2015 +0000
+++ b/IniManager.cpp Tue Jan 26 11:51:08 2016 +0000
@@ -10,6 +10,12 @@
#include "IniManager.h"
+#include "Utility.h" // private memory manager
+#ifndef UTILITY_H
+#define swMalloc malloc // use the standard
+#define swFree free
+#endif
+
//#define DEBUG "INI " //Debug is disabled by default
#include <cstdio>
@@ -35,7 +41,7 @@
INI::~INI(void)
{
if (iniFile)
- free(iniFile);
+ swFree(iniFile);
}
@@ -61,8 +67,8 @@
INFO("SetFile(%s)", file);
if (file) {
if (iniFile)
- free(iniFile);
- iniFile = (char *)malloc(strlen(file)+1);
+ swFree(iniFile);
+ iniFile = (char *)swMalloc(strlen(file)+1);
if (iniFile) {
strcpy(iniFile, file);
INFO(" SetFile(%s) success", iniFile);
@@ -129,8 +135,8 @@
bool INI::CleanUp()
{
- char * newFile = (char *)malloc(strlen(iniFile)+1);
- char * bakFile = (char *)malloc(strlen(iniFile)+1);
+ char * newFile = (char *)swMalloc(strlen(iniFile)+1);
+ char * bakFile = (char *)swMalloc(strlen(iniFile)+1);
if (newFile && bakFile) {
INFO("CleanUp");
@@ -154,8 +160,8 @@
// nothing to do, move on silently.
}
}
- free(newFile);
- free(bakFile);
+ swFree(newFile);
+ swFree(bakFile);
return true;
}
@@ -172,12 +178,12 @@
if (!iniFile || (value != NULL && strlen(value) > INTERNAL_BUF_SIZE))
return found;
- char * newFile = (char *)malloc(strlen(iniFile)+1);
- char * bakFile = (char *)malloc(strlen(iniFile)+1);
+ char * newFile = (char *)swMalloc(strlen(iniFile)+1);
+ char * bakFile = (char *)swMalloc(strlen(iniFile)+1);
if (!newFile)
return found; // no memory
if (!bakFile) {
- free(newFile);
+ swFree(newFile);
return found;
}
strcpy(bakFile, iniFile);
@@ -297,8 +303,8 @@
#endif
INFO(" d");
}
- free(newFile);
- free(bakFile);
+ swFree(newFile);
+ swFree(bakFile);
return found;
}