summaryrefslogtreecommitdiff
path: root/src/string/strerror.c
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2024-05-28 14:56:06 -0400
committerJakob Kaivo <jkk@ung.org>2024-05-28 14:56:06 -0400
commitb4cd7036bea6c6440fbbcdaebe53c864c87a5646 (patch)
tree260670ad9a9637c8c36d84b9cf77ec412017b038 /src/string/strerror.c
parenta69b11fd8974a898a26081950bd4add7c82ea45d (diff)
integrate jkmalloc/prep for readonly
Diffstat (limited to 'src/string/strerror.c')
-rw-r--r--src/string/strerror.c13
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);
*/