[Scummvm-cvs-logs] CVS: scummvm config-file.cpp,1.6,1.7

Nicolas Noble pixels at users.sourceforge.net
Wed May 1 17:58:04 CEST 2002


Update of /cvsroot/scummvm/scummvm
In directory usw-pr-cvs1:/tmp/cvs-serv22565

Modified Files:
	config-file.cpp 
Log Message:
My code really need that free(NULL) is valid BBrox... =)
And arisme you were SOO right! How was my code working before?!?


Index: config-file.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/config-file.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- config-file.cpp	1 May 2002 22:28:05 -0000	1.6
+++ config-file.cpp	2 May 2002 00:46:12 -0000	1.7
@@ -28,6 +28,9 @@
 
 #define MAXLINELEN 256
 
+#define xfree(p) {if (p) free(p);}
+
+
 static char *ltrim(char *t)
 {
 	for (; *t && (*t == ' '); t++);
@@ -72,7 +75,7 @@
 
 hashconfig::~hashconfig()
 {
-	free(domain);
+	xfree(domain);
 }
 
 bool hashconfig::is_domain(const char *d) const
@@ -99,7 +102,7 @@
 
 	for (i = 0; i < nkeys; i++) {
 		if (!strcmp(key, keys[i])) {
-			free(values[i]);
+			xfree(values[i]);
 			return values[i] = value ? Scumm::Strdup(value) : 0;
 		}
 	}
@@ -135,7 +138,7 @@
 
 void hashconfig::rename(const char *d)
 {
-	free(domain);
+	xfree(domain);
 	domain = d ? Scumm::Strdup(d) : 0;
 }
 
@@ -208,13 +211,13 @@
 {
 	int i;
 
-	free(filename);
-	free(domain);
+	xfree(filename);
+	xfree(domain);
 
 	for (i = 0; i < ndomains; i++) {
 		delete hash[i];
 	}
-	free(hash);
+	xfree(hash);
 }
 
 const char *Config::get(const char *key, const char *d) const
@@ -281,7 +284,7 @@
 void Config::set_domain(const char *d)
 {
 	int i;
-	free(domain);
+	xfree(domain);
 	domain = d ? Scumm::Strdup(d) : 0;
 
 	for (i = 0; i < ndomains; i++) {
@@ -346,7 +349,7 @@
 
 void Config::change_filename(const char *f)
 {
-	free(filename);
+	xfree(filename);
 	filename = f ? Scumm::Strdup(f) : 0;
 }
 





More information about the Scummvm-git-logs mailing list