CFileHelpers: Rework FileBuf handling

FileBuf: Reserve memory only when it is needed (copyFile)
copyFile: Reserve for small files, only as much memory as is required


Origin commit data
------------------
Branch: ni/coolstream
Commit: 0a1cdb3d4e
Author: Michael Liebmann <tuxcode.bbg@gmail.com>
Date: 2016-09-06 (Tue, 06 Sep 2016)



------------------
This commit was generated by Migit
This commit is contained in:
Michael Liebmann
2016-09-06 11:30:06 +02:00
committed by vanhofen
parent 9cfb1d7302
commit b2eaf63a6e
2 changed files with 18 additions and 4 deletions

View File

@@ -675,8 +675,21 @@ CFileHelpers::CFileHelpers()
CFileHelpers::~CFileHelpers() CFileHelpers::~CFileHelpers()
{ {
if (FileBuf != NULL) }
delete [] FileBuf;
char* CFileHelpers::initFileBuf(char* buf, uint32_t size)
{
if (buf == NULL)
buf = new char[size];
return buf;
}
char* CFileHelpers::deleteFileBuf(char* buf)
{
if (buf != NULL)
delete [] buf;
buf = NULL;
return buf;
} }
CFileHelpers* CFileHelpers::getInstance() CFileHelpers* CFileHelpers::getInstance()

View File

@@ -86,10 +86,11 @@ struct helpersDebugInfo {
class CFileHelpers class CFileHelpers
{ {
private: private:
unsigned long FileBufSize; uint32_t FileBufMaxSize;
char *FileBuf;
int fd1, fd2; int fd1, fd2;
char* initFileBuf(char* buf, uint32_t size);
char* deleteFileBuf(char* buf);
bool ConsoleQuiet; bool ConsoleQuiet;
helpersDebugInfo DebugInfo; helpersDebugInfo DebugInfo;
void setDebugInfo(const char* msg, const char* file, const char* func, int line); void setDebugInfo(const char* msg, const char* file, const char* func, int line);