[Pinfo-devel] r223 - pinfo/branches/cxx/src

Nathanael Nerode neroden-guest at costa.debian.org
Tue Sep 13 11:32:58 UTC 2005


Author: neroden-guest
Date: 2005-09-13 11:32:57 +0000 (Tue, 13 Sep 2005)
New Revision: 223

Modified:
   pinfo/branches/cxx/src/filehandling_functions.cxx
   pinfo/branches/cxx/src/mainfunction.cxx
Log:
Fix new[]/delete mismatch.


Modified: pinfo/branches/cxx/src/filehandling_functions.cxx
===================================================================
--- pinfo/branches/cxx/src/filehandling_functions.cxx	2005-09-10 17:37:17 UTC (rev 222)
+++ pinfo/branches/cxx/src/filehandling_functions.cxx	2005-09-13 11:32:57 UTC (rev 223)
@@ -613,13 +613,12 @@
 	fseek(id, 0, SEEK_END);
 	filelen = ftell(id);
 
-	char *tmp;
-	tmp = new char[filelen];
+	char *tmp = new char[filelen];
 	fseek(id, 0, SEEK_SET);
 	fread(tmp, 1, filelen, id);
 	fclose(id);
 	string tmpstr = tmp;
-	delete tmp;
+	delete [] tmp;
 
 	id = fopen(tmpfilename.c_str(), "w");
 	bool aswitch = false;

Modified: pinfo/branches/cxx/src/mainfunction.cxx
===================================================================
--- pinfo/branches/cxx/src/mainfunction.cxx	2005-09-10 17:37:17 UTC (rev 222)
+++ pinfo/branches/cxx/src/mainfunction.cxx	2005-09-13 11:32:57 UTC (rev 223)
@@ -409,8 +409,7 @@
 							fseek(fd, FirstNodeOffset, SEEK_SET);
 						starttokenpos = ftell(fd);
 
-						char *tmp;
-						tmp = new char[filelen - starttokenpos + 10];
+						char *tmp = new char[filelen - starttokenpos + 10];
 						/* read data */
 						fread(tmp, 1, filelen - starttokenpos, fd);
 						tmp[filelen - starttokenpos + 1] = 0;
@@ -472,7 +471,7 @@
 							{
 								if (tmp)	/* free tmp buffer */
 								{
-									delete tmp;
+									delete [] tmp;
 									tmp = 0;
 								}
 								break;
@@ -480,7 +479,7 @@
 						}	/* end: if (tokenpos) */
 						if (tmp)	/* free tmp buffer */
 						{
-							delete tmp;
+							delete [] tmp;
 							tmp = 0;
 						}
 					}		/* end: indirect file loop */




More information about the Pinfo-devel mailing list