diff system/system_config.cc @ 50:35ce1a30f3f9

* Added va_end where there is a va_start * Used NULL instead of 0 (so it works on 64b)
author thib
date Fri, 17 Apr 2009 18:38:06 +0000
parents ed6c21dde840
children 15a18fbe6f21
line wrap: on
line diff
--- a/system/system_config.cc
+++ b/system/system_config.cc
@@ -134,6 +134,11 @@ public:
 		old_data = 0;
 		new_data = 0;
 	}
+	~AyuSysConfigStringItem(void) {
+		if (original_data) delete[] original_data;
+		if (old_data) delete[] old_data;
+		if (new_data) delete[] new_data;
+	}
 	AyuSysConfigStringItem(const AyuSysConfigStringItem& o) {
 		original_data = 0; old_data = 0; new_data = 0;
 		if (o.original_data) {
@@ -265,6 +270,11 @@ public:
 		old_data = 0;
 		new_data = 0;
 	}
+	~AyuSysConfigIntlistItem(void) {
+		if (original_data) delete[] original_data;
+		if (old_data) delete[] old_data;
+		if (new_data) delete[] new_data;
+	}
 	AyuSysConfigIntlistItem(const AyuSysConfigIntlistItem& o) {
 		item_deal = o.item_deal;
 		original_data = 0; old_data = 0; new_data = 0;
@@ -545,15 +555,17 @@ int AyuSysConfig::GetParam(const char* n
 		va_start(va, deal);
 		for (i=0; i<deal; i++) {
 			int* var = va_arg(va, int*);
-			if (var) *var = 0;
+			if (var != NULL) *var = 0;
 		}
+		va_end(va);
 		return -1;
 	} else {
 		va_start(va, deal);
 		for (i=0; i<deal; i++) {
 			int* var = va_arg(va, int*);
-			if (var) *var = vars[i];
+			if (var != NULL) *var = vars[i];
 		}
+		va_end(va);
 	}
 	return 0;
 }
@@ -566,15 +578,17 @@ int AyuSysConfig::GetOriginalParam(const
 		va_start(va, deal);
 		for (i=0; i<deal; i++) {
 			int* var = va_arg(va, int*);
-			if (var) *var = 0;
+			if (var != NULL) *var = 0;
 		}
+		va_end(va);
 		return -1;
 	} else {
 		va_start(va, deal);
 		for (i=0; i<deal; i++) {
 			int* var = va_arg(va, int*);
-			if (var) *var = vars[i];
+			if (var != NULL) *var = vars[i];
 		}
+		va_end(va);
 	}
 	return 0;
 }
@@ -594,9 +608,10 @@ void AyuSysConfig::SetParaStr(const char
 void AyuSysConfig::SetParam(const char* name, int deal, ...) {
 	if (deal >= MAXVARS) return ;
 	HashStr str(name);
-	int vars[MAXVARS]; va_list va; int i;
+	int vars[deal]; va_list va; int i;
 	va_start(va, deal);
 	for (i=0; i<deal; i++) vars[i] = va_arg(va, int);
+	va_end(va);
 	int_config->orig.Set(str, deal, vars);
 	dirty_flag = 1; change_flag = 1;
 	return;
@@ -609,9 +624,10 @@ void AyuSysConfig::SetOrigParaStr(const 
 void AyuSysConfig::SetOrigParam(const char* name, int deal, ...) {
 	if (deal >= MAXVARS) return;
 	HashStr str(name);
-	int vars[MAXVARS]; va_list va; int i;
+	int vars[deal]; va_list va; int i;
 	va_start(va, deal);
 	for(i=0; i<deal; i++) vars[i] = va_arg(va, int);
+	va_end(va);
 	int_config->orig.SetOrig(str, deal, vars);
 	change_flag = 1;
 }