Skip to content

Commit 4ccfa12

Browse files
committed
donho review
1 parent ae366df commit 4ccfa12

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

PowerEditor/src/MISC/Common/Common.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,27 @@ wstring commafyInt(size_t n)
5252

5353
std::string getFileContent(const wchar_t* file2read, bool* pbFailed)
5454
{
55-
if (pbFailed) *pbFailed = false; // reset
55+
if (pbFailed)
56+
*pbFailed = false; // reset
5657

5758
if (!doesFileExist(file2read))
5859
{
59-
if (pbFailed) *pbFailed = true;
60+
if (pbFailed)
61+
*pbFailed = true;
6062
return "";
6163
}
6264

6365
FILE* fp = _wfopen(file2read, L"rb");
6466
if (!fp)
6567
{
66-
if (pbFailed) *pbFailed = true;
68+
if (pbFailed)
69+
*pbFailed = true;
6770
return "";
6871
}
6972

7073
static constexpr size_t blockSize = 1024 * 4; // 4K is optimal chunk for memory, cache, disk or network
7174
char data[blockSize];
72-
std::string wholeFileContent = "";
75+
std::string wholeFileContent;
7376
size_t lenFile = 0;
7477
try
7578
{
@@ -82,14 +85,16 @@ std::string getFileContent(const wchar_t* file2read, bool* pbFailed)
8285
}
8386
catch ([[maybe_unused]] const std::bad_alloc& ex)
8487
{
85-
if (pbFailed) *pbFailed = true;
88+
if (pbFailed)
89+
*pbFailed = true;
8690
std::string().swap(wholeFileContent); // to immediately release all the allocated memory
8791
::MessageBoxW(NULL, L"std::bad_alloc exception caught!\n\nProbably not enough contiguous memory to complete the operation.",
8892
L"Notepad++ - getFileContent", MB_OK | MB_ICONWARNING | MB_APPLMODAL);
8993
}
9094
catch (...)
9195
{
92-
if (pbFailed) *pbFailed = true;
96+
if (pbFailed)
97+
*pbFailed = true;
9398
std::string().swap(wholeFileContent); // to immediately release all the allocated memory
9499
}
95100

0 commit comments

Comments
 (0)