changeset 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 6581f7eccd26
children cbb301016a4e
files font/font_layout.cc music2/koedec.cc scn2k/scn2k_grp.cc scn2k/scn2k_impl.cc scn2k/scn2k_text.cc system/file.cc system/file_impl.h system/system_config.cc
diffstat 8 files changed, 37 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/font/font_layout.cc
+++ b/font/font_layout.cc
@@ -131,6 +131,7 @@ TextGlyphStreamHelper::Add(int& x, TextG
 				gl.g = g = it->impl.Color.g;
 				gl.b = b = it->impl.Color.b;
 			} else if (it->type == TextElem::size) {
+				delete face;
 				face = font->FaceLoad(it->impl.Size.scale);
 			} else if (it->type == TextElem::escape) {
 				x = gl.x;
--- a/music2/koedec.cc
+++ b/music2/koedec.cc
@@ -114,13 +114,17 @@ AvgKoeInfo AvgKoeCache::Find(int file_nu
 			//FIXME: OMG that's ugly, improve it as soon as you can!
 			DIRFILE* koedir = (DIRFILE*) file_searcher.MakeARCFILE((FILESEARCH::ARCTYPE)0, "koe");
 			sprintf(fname, "%04d", file_number);
-			koedir = new DIRFILE(koedir->SearchFile(fname));
+			char* dirname = koedir->SearchFile(fname);
+			delete koedir;
+			koedir = new DIRFILE(dirname);
+			delete[] dirname;
 			sprintf(fname, "z%04d%05d.ogg", file_number, index);
 			arcinfo = koedir->Find(fname, ".ogg");
 			delete koedir;
 
 			if (arcinfo == 0) return info;
 			FILE* stream = arcinfo->OpenFile(&info.length);
+			delete arcinfo;
 			info.type = koe_ogg;
 			info.stream = stream;
 			return info;
--- a/scn2k/scn2k_grp.cc
+++ b/scn2k/scn2k_grp.cc
@@ -510,6 +510,7 @@ TextStream GrpObj::ParseMoji(const char* str, int def_r ,int def_g, int def_b, int def_size) { // 制御シーケンス付き文字列をparse
 		}
 	}
 	ts.Add(str);
+	delete[] copy_str;
 	return ts;
 }
 void GrpObj::UpdateMoji(void) { // 文字の大きさ、色などを変更
@@ -845,6 +846,7 @@ GrpImpl::~GrpImpl() {
 	delete screen;
 	delete screen_front;
 	parent.Root().DeleteSurface(surface);
+	parent.Root().DeleteSurface(surface_update);
 	int i;
 	for (i=0; i<MAXPDT; i++) {
 		if (ssurface[i]) parent.Root().DeleteSurface(ssurface[i]);
--- a/scn2k/scn2k_impl.cc
+++ b/scn2k/scn2k_impl.cc
@@ -87,6 +87,7 @@ Scn2k::Scn2k(Event::Container& _event, P
 }
 
 Scn2k::~Scn2k() {
+	if (script_start) delete[] script_start;
 	HideCursor();
 	SaveSys();
 }
@@ -750,7 +751,7 @@ void Scn2k::SysExec(Cmd& cmd) {
 			cmd.clear();
 		} else if (cmd.cmd3 == 0x4b0) { // 終了
 			System::Main::Quit();
-			script = 0; script_start = 0; script_end = 0;
+			//script = 0; script_start = 0; script_end = 0;
 			cmd.clear();
 			cmd.cmd_type = CMD_WAITFRAMEUPDATE;
 		} else if (cmd.cmd3 == 0x4b4 || cmd.cmd3 == 0x4b5) { // 選択肢巻き戻し
@@ -1216,6 +1217,8 @@ void Scn2k::Load(Cmd& cmd) {
 		grp_exec.Exec(cmd);
 	}
 	cmd.clear();
+
+	delete[] savedata;
 	return;
 }
 
--- a/scn2k/scn2k_text.cc
+++ b/scn2k/scn2k_text.cc
@@ -1914,7 +1914,7 @@ TextWindow::TextWindow(PicContainer& par
 	sprintf(key, "#WINDOW.%03d.MOJI_REP", win_no);  if (config.GetParam(key, 2, &rep1, &rep2) == -1) return;
 	sprintf(key, "#WINDOW.%03d.MOJI_CNT", win_no);  if (config.GetParam(key, 2, &cntw, &cnth) == -1) return;
 	sprintf(key, "#WINDOW.%03d.POS", win_no);       if (config.GetParam(key, 3, &posd, &posx, &posy) == -1) return;
-	sprintf(key, "#WINDOW.%03d.MOJI_POS", win_no);  if (config.GetParam(key, 4, &mposy, 0, &mposx, 0) == -1) return;
+	sprintf(key, "#WINDOW.%03d.MOJI_POS", win_no);  if (config.GetParam(key, 4, &mposy, NULL, &mposx, NULL) == -1) return;
 	sprintf(key, "#WINDOW.%03d.MOJI_MIN", win_no);  if (config.GetParam(key, 2, &minx, &miny) == -1) return;
 	sprintf(key, "#WINDOW.%03d.WAKU_SETNO", win_no);if (config.GetParam(key, 1, &waku_no) == -1) return;
 	sprintf(key, "#WINDOW.%03d.LUBY_SIZE", win_no); if (config.GetParam(key, 1, &ruby) == -1) return;
--- a/system/file.cc
+++ b/system/file.cc
@@ -149,6 +149,7 @@ void ARCFILE::Init(void) {
 ARCFILE::~ARCFILE() {
 	if (filenames_orig) delete[] filenames_orig;
 	delete[] arcname;
+	delete next;
 }
 
 ARCFILE::iterator ARCFILE::SearchName(const char* f, const char* ext) {
--- a/system/file_impl.h
+++ b/system/file_impl.h
@@ -62,7 +62,7 @@ protected:
 	iterator SearchName(const char* f, const char* ext=0);
 public:
 	ARCFILE(const char* fname);
-	void SetNext(ARCFILE* _next) { next = _next;}
+	void SetNext(ARCFILE* _next) { delete next; next = _next;}
 	ARCFILE* Next(void) { return next; }
 	void Init(void);
 	virtual ~ARCFILE();
--- 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;
 }