From b4cd7036bea6c6440fbbcdaebe53c864c87a5646 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Tue, 28 May 2024 14:56:06 -0400 Subject: integrate jkmalloc/prep for readonly --- src/string/strerror.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/string') diff --git a/src/string/strerror.c b/src/string/strerror.c index 69984886..5f83b2c4 100644 --- a/src/string/strerror.c +++ b/src/string/strerror.c @@ -2,17 +2,22 @@ #include #include #include "_safety.h" - -# define __LONGEST_STRERR 64 /* FIXME */ +#include "_readonly.h" /** convert error number to string **/ char * strerror(int errnum) { - static char errstr[__LONGEST_STRERR+1]; + static char *errstr = NULL; SIGNAL_SAFE(0); + if (errstr == NULL) { + errstr = __readonly(RO_ALLOC, "strerror"); + } + + __readonly(RO_UNLOCK, errstr); + switch (errnum) { #include "_strerror.h" default: @@ -20,6 +25,8 @@ char * strerror(int errnum) break; } + __readonly(RO_LOCK, errstr); + /* RETURN_ALWAYS(a pointer to the message string); */ -- cgit v1.2.1