Skip to content

Commit 6b394f2

Browse files
committed
remove overzealous sizeof() usage
1 parent 8cd6179 commit 6b394f2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/file_helpers.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@ std::string promptForFilename(std::string initName) {
4040
using namespace std::placeholders;
4141

4242
// Register the callback which creates the UI and does the hard work
43-
char* textBuff = new char[2048];
44-
snprintf(textBuff, sizeof(textBuff), "%s", initName.c_str());
45-
auto func = std::bind(filenamePromptCallback, textBuff, 2048);
43+
const size_t BUFF_LEN = 2048;
44+
char* textBuff = new char[BUFF_LEN];
45+
snprintf(textBuff, BUFF_LEN, "%s", initName.c_str());
46+
auto func = std::bind(filenamePromptCallback, textBuff, BUFF_LEN);
4647
pushContext(func);
4748

4849
std::string stringOut(textBuff);

0 commit comments

Comments
 (0)