From 5d528fffb27e13710ed51d078c020b0879597083 Mon Sep 17 00:00:00 2001 From: Jan Date: Mon, 14 Oct 2019 15:28:25 +0200 Subject: [PATCH] fix leak in hot backup tests (#10245) --- tests/RocksDBEngine/ShaEventListener.cpp | 38 ++++++++++-------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/tests/RocksDBEngine/ShaEventListener.cpp b/tests/RocksDBEngine/ShaEventListener.cpp index f454e43b5d..2a46563bd3 100644 --- a/tests/RocksDBEngine/ShaEventListener.cpp +++ b/tests/RocksDBEngine/ShaEventListener.cpp @@ -69,46 +69,40 @@ struct CFilesSetup { TRI_RemoveDirectory(_directory.c_str()); } - StringBuffer* writeFile (const char* blob) { - StringBuffer* filename = new StringBuffer(true); - filename->appendText(_directory); - filename->appendChar(TRI_DIR_SEPARATOR_CHAR); - filename->appendText("tmp-"); - filename->appendInteger(++counter); - filename->appendInteger(arangodb::RandomGenerator::interval(UINT32_MAX)); + void writeFile(char const* blob) { + StringBuffer filename(true); + filename.appendText(_directory); + filename.appendChar(TRI_DIR_SEPARATOR_CHAR); + filename.appendText("tmp-"); + filename.appendInteger(++counter); + filename.appendInteger(arangodb::RandomGenerator::interval(UINT32_MAX)); - FILE* fd = fopen(filename->c_str(), "wb"); + FILE* fd = fopen(filename.c_str(), "wb"); if (fd) { size_t numWritten = fwrite(blob, strlen(blob), 1, fd); (void) numWritten; fclose(fd); - } - else { + } else { EXPECT_TRUE(false); } - - return filename; } - StringBuffer * writeFile (const char * name, const char * blob) { - StringBuffer* filename = new StringBuffer(true); - filename->appendText(_directory); - filename->appendChar(TRI_DIR_SEPARATOR_CHAR); - filename->appendText(name); + void writeFile(char const* name, char const* blob) { + StringBuffer filename(true); + filename.appendText(_directory); + filename.appendChar(TRI_DIR_SEPARATOR_CHAR); + filename.appendText(name); - FILE* fd = fopen(filename->c_str(), "wb"); + FILE* fd = fopen(filename.c_str(), "wb"); if (fd) { size_t numWritten = fwrite(blob, strlen(blob), 1, fd); (void) numWritten; fclose(fd); - } - else { + } else { EXPECT_TRUE(false); } - - return filename; } StringBuffer _directory;