Revert "follow-up: use only the memory that's required"
This reverts commit 4a0654c708.
This commit is contained in:
@@ -12,7 +12,7 @@ extern "C" {
|
|||||||
#include <hack.h>
|
#include <hack.h>
|
||||||
|
|
||||||
extern const char regex_id[] = "cppregex";
|
extern const char regex_id[] = "cppregex";
|
||||||
static char *cppregex_static_buffer = (char *) 0;
|
static char cppregex_static_buffer[BUFSZ];
|
||||||
|
|
||||||
struct nhregex {
|
struct nhregex {
|
||||||
std::unique_ptr<std::regex> re;
|
std::unique_ptr<std::regex> re;
|
||||||
@@ -41,9 +41,8 @@ extern "C" {
|
|||||||
|
|
||||||
const char *regex_error_desc(struct nhregex *re) {
|
const char *regex_error_desc(struct nhregex *re) {
|
||||||
if (re->err) {
|
if (re->err) {
|
||||||
if (cppregex_static_buffer != 0)
|
Snprintf(cppregex_static_buffer, sizeof cppregex_static_buffer,
|
||||||
free(cppregex_static_buffer);
|
"%s", re->err->what());
|
||||||
cppregex_static_buffer = dupstr(re->err->what());
|
|
||||||
return cppregex_static_buffer;
|
return cppregex_static_buffer;
|
||||||
} else
|
} else
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|||||||
Reference in New Issue
Block a user