diff options
Diffstat (limited to 'src/string/strerror.c')
-rw-r--r-- | src/string/strerror.c | 13 |
1 files changed, 10 insertions, 3 deletions
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 <stdio.h> #include <string.h> #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); */ |