Revert "follow-up: use only the memory that's required"

This reverts commit 4a0654c708.
This commit is contained in:
nhmall
2022-06-30 22:38:14 -04:00
parent 66a1e19d26
commit 751b6e646f

View File

@@ -12,7 +12,7 @@ extern "C" {
#include <hack.h>
extern const char regex_id[] = "cppregex";
static char *cppregex_static_buffer = (char *) 0;
static char cppregex_static_buffer[BUFSZ];
struct nhregex {
std::unique_ptr<std::regex> re;
@@ -41,9 +41,8 @@ extern "C" {
const char *regex_error_desc(struct nhregex *re) {
if (re->err) {
if (cppregex_static_buffer != 0)
free(cppregex_static_buffer);
cppregex_static_buffer = dupstr(re->err->what());
Snprintf(cppregex_static_buffer, sizeof cppregex_static_buffer,
"%s", re->err->what());
return cppregex_static_buffer;
} else
return nullptr;