فهرست منبع

Arrays allocated with new[] must be deleted with delete[]

Michał W. Urbańczyk 18 سال پیش
والد
کامیت
06a081c924
5فایلهای تغییر یافته به همراه11 افزوده شده و 11 حذف شده
  1. 1 1
      CAdvmapInterface.cpp
  2. 2 2
      CPlayerInterface.cpp
  3. BIN
      CPreGame.cpp
  4. 7 7
      hch/CLodHandler.cpp
  5. 1 1
      hch/CLodHandler.h

+ 1 - 1
CAdvmapInterface.cpp

@@ -1142,7 +1142,7 @@ void CResDataBar::draw()
 	printAt(processStr(datetext,temp),txtpos[7].first,txtpos[7].second,GEOR13,zwykly);
 	temp.clear();
 	//updateRect(&pos,ekran);
-	delete buf;
+	delete[] buf;
 }
 CInfoBar::CInfoBar()
 {

+ 2 - 2
CPlayerInterface.cpp

@@ -1142,7 +1142,7 @@ SDL_Surface * CPlayerInterface::drawPrimarySkill(const CGHeroInstance *curh, SDL
 		itoa(curh->primSkills[i],buf,10);
 		printAtMiddle(buf,84+28*i,68,GEOR13,zwykly,ret);
 	}
-	delete buf;
+	delete[] buf;
 	return ret;
 }
 SDL_Surface * CPlayerInterface::drawHeroInfoWin(const CGHeroInstance * curh)
@@ -1162,7 +1162,7 @@ SDL_Surface * CPlayerInterface::drawHeroInfoWin(const CGHeroInstance * curh)
 	blitAt(curh->type->portraitLarge,11,12,ret);
 	itoa(curh->mana,buf,10);
 	printAtMiddle(buf,166,109,GEORM,zwykly,ret); //mana points
-	delete buf;
+	delete[] buf;
 	blitAt(morale22->ourImages[curh->getCurrentMorale()+3].bitmap,14,84,ret);
 	blitAt(luck22->ourImages[curh->getCurrentLuck()+3].bitmap,14,101,ret);
 	//SDL_SaveBMP(ret,"inf1.bmp");

BIN
CPreGame.cpp


+ 7 - 7
hch/CLodHandler.cpp

@@ -411,7 +411,7 @@ CDefHandler * CLodHandler::giveDef(std::string defName)
 		nh->alphaTransformed = false;
 		ret = nh;
 	}
-	delete outp;
+	delete[] outp;
 	return ret;
 }
 CDefEssential * CLodHandler::giveDefEss(std::string defName)
@@ -473,7 +473,7 @@ std::vector<CDefHandler *> CLodHandler::extractManyFiles(std::vector<std::string
 			nh->alphaTransformed = false;
 			ret[curDef] = nh;
 		}
-		delete outp;
+		delete[] outp;
 	}
 	//std::cout<<'\r'<<"Reading defs: 100%    "<<std::endl;
 	for(int hh=0; hh<found.size(); ++hh)
@@ -697,7 +697,7 @@ void CLodHandler::extract(std::string FName)
 				std::cout<<"LOD Extraction error"<<"  "<<decRes<<" while extracting to "<<bufff<<std::endl;
 			}
 		}
-		delete outp;
+		delete[] outp;
 	}
 	FLOD.close();
 }
@@ -748,7 +748,7 @@ void CLodHandler::extractFile(std::string FName, std::string name)
 				std::cout<<"LOD Extraction error"<<"  "<<decRes<<" while extracting to "<<bufff<<std::endl;
 			}
 		}
-		delete outp;
+		delete[] outp;
 	}
 	FLOD.close();
 }
@@ -834,7 +834,7 @@ std::string CLodHandler::getTextFile(std::string name)
 			outp = new unsigned char[entries[i].realSize];
 			FLOD.read((char*)outp, entries[i].realSize);
 			std::string ret = std::string((char*)outp);
-			delete outp;
+			delete[] outp;
 			return ret;
 		}
 		else //we will decompressing file
@@ -847,8 +847,8 @@ std::string CLodHandler::getTextFile(std::string name)
 			std::string ret;
 			for (int itr=0;itr<entries[i].realSize;itr++)
 				ret+= *((char*)decomp+itr);
-			delete outp;
-			delete decomp;
+			delete[] outp;
+			delete[] decomp;
 			return ret;
 		}
 	}

+ 1 - 1
hch/CLodHandler.h

@@ -47,7 +47,7 @@ public:
 	void convert();
 	SDL_Surface * getSurface();
 	CPCXConv(){pcx=bmp=NULL;pcxs=bmps=0;};
-	~CPCXConv(){if (pcxs) delete pcx; if(bmps) delete bmp;}
+	~CPCXConv(){if (pcxs) delete[] pcx; if(bmps) delete[] bmp;}
 };
 class CLodHandler
 {