diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/u8c/dattyp.h | 3 | ||||
-rw-r--r-- | src/u8c/end.c | 1 | ||||
-rw-r--r-- | src/u8c/init.c | 7 |
3 files changed, 10 insertions, 1 deletions
diff --git a/src/u8c/dattyp.h b/src/u8c/dattyp.h index 1a1e830..aa61b21 100644 --- a/src/u8c/dattyp.h +++ b/src/u8c/dattyp.h @@ -16,6 +16,7 @@ # if !defined(u8c_sym_dattyp) # define u8c_sym_dattyp # include <stdbool.h> +# include <stddef.h> # include <stdint.h> # include <u8c/errhandltyp.h> # include <u8c/errtyp.h> @@ -28,7 +29,7 @@ struct u8c_dattyp { bool fmtendian; unsigned char pad0[sizeof(void(*)(void)) - SIZE_C(0x1)]; /* Padding. */ char32_t const * err; - u8c_errhandltyp errhandls[u8c_errtyp_maxerrtyp]; + u8c_errhandltyp errhandls[(size_t)u8c_errtyp_maxerrtyp]; uint_least8_t fmtbase; uint_least8_t stat; # if defined(u8c_bethrdsafe) diff --git a/src/u8c/end.c b/src/u8c/end.c index adfd8d6..80d39aa 100644 --- a/src/u8c/end.c +++ b/src/u8c/end.c @@ -29,6 +29,7 @@ bool u8c_end(void) { } # if defined(u8c_bethrdsafe) /* Destroy mutexes: */ + mtx_destroy(&u8c_dat.errhandlslock); mtx_destroy(&u8c_dat.errlock); mtx_destroy(&u8c_dat.fmtlock); # endif diff --git a/src/u8c/init.c b/src/u8c/init.c index f2e4948..0b8a100 100644 --- a/src/u8c/init.c +++ b/src/u8c/init.c @@ -28,6 +28,9 @@ bool u8c_init() { /* Initialise mutexes: */ # if defined(u8c_bethrdsafe) + if(mtx_init(&u8c_dat.errhandlslock,mtx_plain) == thrd_error) { + return true; + } if(mtx_init(&u8c_dat.errlock,mtx_plain) == thrd_error) { return true; } @@ -38,6 +41,10 @@ bool u8c_init() { /* Set default error message: */ u8c_dat.err = NULL; u8c_seterr(U"",u8c_errtyp_deferr); + /* Initialise error handler array: */ + for(register size_t n = SIZE_C(0x0);n < u8c_errtyp_maxerrtyp;n += SIZE_C(0x1)) { + u8c_dat.errhandls[n] = NULL; + } /* Set status: */ u8c_dat.stat = UINT8_C(0x1); return false; |