system/flashtool.cpp: use buffer on stack

This commit is contained in:
[CST] Focus
2013-05-21 16:54:05 +04:00
parent 142d7c204c
commit 3959771c18

View File

@@ -100,13 +100,7 @@ bool CFlashTool::readFromMTD( const std::string & filename, int globalProgressEn
filesize = CMTDInfo::getInstance()->getMTDSize(mtdDevice);
unsigned char * buf = new unsigned char[meminfo.writesize];
if (buf == NULL) {
printf("CFlashTool::program: mem alloc failed\n");
close(fd);
close(fd1);
return false;
}
unsigned char buf[meminfo.writesize];
unsigned mtdoffset = 0;
long fsize = filesize;
while(fsize > 0) {
@@ -149,7 +143,6 @@ bool CFlashTool::readFromMTD( const std::string & filename, int globalProgressEn
if(statusViewer)
statusViewer->showLocalStatus(100);
delete[] buf;
close(fd);
close(fd1);
return true;
@@ -210,13 +203,7 @@ bool CFlashTool::program( const std::string & filename, int globalProgressEndEra
if(statusViewer)
globalProgressBegin = statusViewer->getGlobalStatus();
unsigned char * buf = new unsigned char[meminfo.writesize];
if (buf == NULL) {
printf("CFlashTool::program: mem alloc failed\n");
close(fd);
close(fd1);
return false;
}
unsigned char buf[meminfo.writesize];
unsigned mtdoffset = 0;
unsigned fsize = filesize;
printf("CFlashTool::program: file %s write size %d, erase size %d\n", filename.c_str(), meminfo.writesize, meminfo.erasesize);
@@ -269,7 +256,6 @@ bool CFlashTool::program( const std::string & filename, int globalProgressEndEra
if(statusViewer)
statusViewer->showLocalStatus(100);
delete[] buf;
close(fd1);
close(fd);
// FIXME error message
@@ -289,7 +275,7 @@ bool CFlashTool::getInfo()
meminfo.writesize = 1024;
isnand = (meminfo.type == MTD_NANDFLASH);
printf("CFlashTool::getInfo: NAND: %s\n", isnand ? "yes" : "no");
printf("CFlashTool::getInfo: NAND: %s writesize %d\n", isnand ? "yes" : "no", meminfo.writesize);
return true;
}