mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-10 02:08:20 +00:00
Remove unused MD5 functions and fixed memory leak
This commit is contained in:
parent
830cf22beb
commit
9e032223eb
@ -115,14 +115,6 @@ MD5::MD5(const std::string &text)
|
||||
finalize();
|
||||
}
|
||||
|
||||
// raw md5 construstor
|
||||
MD5::MD5(const char * input, size_type length)
|
||||
{
|
||||
init();
|
||||
update(input, length);
|
||||
finalize();
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
|
||||
void MD5::init()
|
||||
|
@ -54,7 +54,6 @@ public:
|
||||
|
||||
MD5();
|
||||
MD5(const std::string& text);
|
||||
MD5(const char * input, size_type length);
|
||||
void update(const unsigned char *buf, size_type length);
|
||||
void update(const char *buf, size_type length);
|
||||
MD5& finalize();
|
||||
|
@ -243,13 +243,16 @@ int main(int argc, char** argv) {
|
||||
const int bufferSize = 1024;
|
||||
MD5* md5 = new MD5();
|
||||
|
||||
std::vector<char> fileStreamBuffer = std::vector<char>(bufferSize, 0);
|
||||
|
||||
while (!fileStream.eof()) {
|
||||
char * fileStreamBuffer = new char[bufferSize];
|
||||
fileStream.read(fileStreamBuffer, bufferSize);
|
||||
std::streamsize size = ((fileStream) ? bufferSize : fileStream.gcount());
|
||||
md5->update(fileStreamBuffer, size);
|
||||
fileStreamBuffer.clear();
|
||||
fileStream.read(fileStreamBuffer.data(), bufferSize);
|
||||
md5->update(fileStreamBuffer.data(), fileStream.gcount());
|
||||
}
|
||||
|
||||
fileStreamBuffer.clear();
|
||||
|
||||
const char* nullTerminateBuffer = "\0";
|
||||
md5->update(nullTerminateBuffer, 1); // null terminate the data
|
||||
md5->finalize();
|
||||
|
Loading…
Reference in New Issue
Block a user