Skip to content

Commit

Permalink
Reduce buffer variable scope
Browse files Browse the repository at this point in the history
  • Loading branch information
melroy89 committed Jun 22, 2024
1 parent f037fe6 commit 98b35b2
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1541,13 +1541,12 @@ string Helper::string_to_icon(const std::string& string)
*/
std::pair<int, string> Helper::exec(const string& command)
{
// Max 128 characters
std::array<char, 128> buffer{};
int exit_code = -1;
string output = "";

// local scope kicks off pclose before returning exit_code
{
std::array<char, 128> buffer{};
// And use the standard C pclose method during stream closure.
auto deleter = [&exit_code](std::FILE* ptr) { exit_code = pclose(ptr); };

Expand Down

0 comments on commit 98b35b2

Please sign in to comment.