Skip to content

Commit

Permalink
Merge pull request #792 from artiomn/master
Browse files Browse the repository at this point in the history
Fix double free (#790)
  • Loading branch information
rdementi committed Jul 17, 2024
2 parents 4c5e585 + 2997904 commit 2f9b0c2
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Copyright (c) 2009-2022, Intel Corporation
// written by Andrey Semin and many others

#include <array>
#include <iostream>
#include <cassert>
#include <climits>
Expand Down Expand Up @@ -125,18 +126,24 @@ const char * setColor (const char * colorStr)
return colorEnabled ? colorStr : "";
}

std::vector<const char *> colorTable = {
ASCII_GREEN,
ASCII_YELLOW,
ASCII_MAGENTA,
ASCII_CYAN,
ASCII_BRIGHT_GREEN,
ASCII_BRIGHT_YELLOW,
ASCII_BRIGHT_BLUE,
ASCII_BRIGHT_MAGENTA,
ASCII_BRIGHT_CYAN,
ASCII_BRIGHT_WHITE
};
template<typename T, typename... N>
constexpr auto make_array(N&&... args) -> std::array<T, sizeof...(args)>
{
return {std::forward<N>(args)...};
}

constexpr auto colorTable{make_array<const char*>(
ASCII_GREEN,
ASCII_YELLOW,
ASCII_MAGENTA,
ASCII_CYAN,
ASCII_BRIGHT_GREEN,
ASCII_BRIGHT_YELLOW,
ASCII_BRIGHT_BLUE,
ASCII_BRIGHT_MAGENTA,
ASCII_BRIGHT_CYAN,
ASCII_BRIGHT_WHITE
)};

size_t currentColor = 0;
const char * setNextColor()
Expand Down

0 comments on commit 2f9b0c2

Please sign in to comment.