summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/u8c/end.c3
-rw-r--r--src/u8c/err.c2
-rw-r--r--src/u8c/err.h2
-rw-r--r--src/u8c/fmt.c2
-rw-r--r--src/u8c/geterr.c2
-rw-r--r--src/u8c/isalnum.c2
-rw-r--r--src/u8c/isalpha.c2
-rw-r--r--src/u8c/iscntrl.c2
-rw-r--r--src/u8c/isdigit.c2
-rw-r--r--src/u8c/ispunct.c2
-rw-r--r--src/u8c/isspace.c2
-rw-r--r--src/u8c/print.c2
-rw-r--r--src/u8c/println.c2
-rw-r--r--src/u8c/seterr.c5
-rw-r--r--src/u8c/u32cmp.c2
-rw-r--r--src/u8c/u32cp.c7
-rw-r--r--src/u8c/u32sz.c2
-rw-r--r--src/u8c/u8dec.c13
-rw-r--r--src/u8c/u8enc.c2
-rw-r--r--src/u8c/vfmt.c2
-rw-r--r--src/u8c/vprint.c12
21 files changed, 39 insertions, 33 deletions
diff --git a/src/u8c/end.c b/src/u8c/end.c
index 924540b..8cd243d 100644
--- a/src/u8c/end.c
+++ b/src/u8c/end.c
@@ -19,6 +19,7 @@
# include <stdint.h>
# include <stdlib.h>
# include <u8c/end.h>
+# include <u8c/freeu32.h>
# if defined(u8c_bethrdsafe)
# include <threads.h>
# endif
@@ -29,7 +30,7 @@ uint_least8_t u8c_end(void) {
# if defined(u8c_bethrdsafe)
mtx_destroy(&u8c_errlock);
# endif
- free(u8c_err);
+ u8c_freeu32(u8c_err);
u8c_stat = UINT8_C(0x1);
return UINT8_C(0x0);
}
diff --git a/src/u8c/err.c b/src/u8c/err.c
index 6c7a940..77a8221 100644
--- a/src/u8c/err.c
+++ b/src/u8c/err.c
@@ -16,4 +16,4 @@
# include "err.h"
# include <stddef.h>
# include <stdint.h>
-uint_least32_t * u8c_err = NULL;
+uint_least32_t const * u8c_err = NULL;
diff --git a/src/u8c/err.h b/src/u8c/err.h
index 895710d..1537701 100644
--- a/src/u8c/err.h
+++ b/src/u8c/err.h
@@ -16,5 +16,5 @@
# if !defined(u8c_sym_err)
# define u8c_sym_err
# include <stdint.h>
-extern uint_least32_t * u8c_err;
+extern uint_least32_t const * u8c_err;
# endif
diff --git a/src/u8c/fmt.c b/src/u8c/fmt.c
index fe59af6..67015da 100644
--- a/src/u8c/fmt.c
+++ b/src/u8c/fmt.c
@@ -18,7 +18,7 @@
# include <stdint.h>
# include <u8c/fmt.h>
# include <u8c/vfmt.h>
-uint_least8_t u8c_fmt(size_t * const _outsz,uint_least32_t * * const _out,uint_least32_t * const _in,...) {
+uint_least8_t u8c_fmt(size_t * const _outsz,uint_least32_t const * * const _out,uint_least32_t const * const _in,...) {
va_list args;
va_start(args,_in);
uint_least8_t val = u8c_vfmt(_outsz,_out,_in,args);
diff --git a/src/u8c/geterr.c b/src/u8c/geterr.c
index 88ec264..d18f696 100644
--- a/src/u8c/geterr.c
+++ b/src/u8c/geterr.c
@@ -19,7 +19,7 @@
# include <stdint.h>
# include <u8c/geterr.h>
# include <u8c/u32cp.h>
-uint_least8_t u8c_geterr(size_t * const _sz,uint_least32_t * * const _out) {
+uint_least8_t u8c_geterr(size_t * const _sz,uint_least32_t const * * const _out) {
# if defined(u8c_bethrdsafe)
mtx_lock(&u8c_errlock);
# endif
diff --git a/src/u8c/isalnum.c b/src/u8c/isalnum.c
index d2ab013..ae2e4c8 100644
--- a/src/u8c/isalnum.c
+++ b/src/u8c/isalnum.c
@@ -19,7 +19,7 @@
# include <u8c/isalnum.h>
# include <u8c/isalpha.h>
# include <u8c/isdigit.h>
-uint_least8_t u8c_isalnum(uint_least8_t * const _res,uint_least32_t _chr) {
+uint_least8_t u8c_isalnum(uint_least8_t * const _res,uint_least32_t const _chr) {
assert(_res != NULL);
uint_least8_t res = UINT8_C(0x0);
u8c_isalpha(&res,_chr);
diff --git a/src/u8c/isalpha.c b/src/u8c/isalpha.c
index 75f3586..bc6d5c0 100644
--- a/src/u8c/isalpha.c
+++ b/src/u8c/isalpha.c
@@ -17,7 +17,7 @@
# include <stddef.h>
# include <stdint.h>
# include <u8c/isalpha.h>
-uint_least8_t u8c_isalpha(uint_least8_t * const _res,uint_least32_t _chr) {
+uint_least8_t u8c_isalpha(uint_least8_t * const _res,uint_least32_t const _chr) {
assert(_res != NULL);
switch(_chr) {
default:
diff --git a/src/u8c/iscntrl.c b/src/u8c/iscntrl.c
index dfd82ed..75d3fa5 100644
--- a/src/u8c/iscntrl.c
+++ b/src/u8c/iscntrl.c
@@ -17,7 +17,7 @@
# include <stddef.h>
# include <stdint.h>
# include <u8c/iscntrl.h>
-uint_least8_t u8c_iscntrl(uint_least8_t * const _res,uint_least32_t _chr) {
+uint_least8_t u8c_iscntrl(uint_least8_t * const _res,uint_least32_t const _chr) {
assert(_res != NULL);
switch(_chr) {
default:
diff --git a/src/u8c/isdigit.c b/src/u8c/isdigit.c
index 1d5e35f..ebfd7c2 100644
--- a/src/u8c/isdigit.c
+++ b/src/u8c/isdigit.c
@@ -17,7 +17,7 @@
# include <stddef.h>
# include <stdint.h>
# include <u8c/isdigit.h>
-uint_least8_t u8c_isdigit(uint_least8_t * const _res,uint_least32_t _chr) {
+uint_least8_t u8c_isdigit(uint_least8_t * const _res,uint_least32_t const _chr) {
assert(_res != NULL);
switch(_chr) {
default:
diff --git a/src/u8c/ispunct.c b/src/u8c/ispunct.c
index 11a155a..abdd72b 100644
--- a/src/u8c/ispunct.c
+++ b/src/u8c/ispunct.c
@@ -17,7 +17,7 @@
# include <stddef.h>
# include <stdint.h>
# include <u8c/ispunct.h>
-uint_least8_t u8c_ispunct(uint_least8_t * const _res,uint_least32_t _chr) {
+uint_least8_t u8c_ispunct(uint_least8_t * const _res,uint_least32_t const _chr) {
assert(_res != NULL);
switch(_chr) {
default:
diff --git a/src/u8c/isspace.c b/src/u8c/isspace.c
index 3bd8b96..8b1ad9b 100644
--- a/src/u8c/isspace.c
+++ b/src/u8c/isspace.c
@@ -17,7 +17,7 @@
# include <stddef.h>
# include <stdint.h>
# include <u8c/isspace.h>
-uint_least8_t u8c_isspace(uint_least8_t * const _res,uint_least32_t _chr) {
+uint_least8_t u8c_isspace(uint_least8_t * const _res,uint_least32_t const _chr) {
assert(_res != NULL);
switch(_chr) {
default:
diff --git a/src/u8c/print.c b/src/u8c/print.c
index f982a25..d8fb7d7 100644
--- a/src/u8c/print.c
+++ b/src/u8c/print.c
@@ -17,7 +17,7 @@
# include <stdint.h>
# include <u8c/print.h>
# include <u8c/vprint.h>
-uint_least8_t u8c_print(FILE * _fp,uint_least32_t * const _msg,...) {
+uint_least8_t u8c_print(FILE * _fp,uint_least32_t const * const _msg,...) {
va_list args;
va_start(args,_msg);
uint_least8_t val = u8c_vprint(_fp,_msg,args);
diff --git a/src/u8c/println.c b/src/u8c/println.c
index f21bba0..dcf592d 100644
--- a/src/u8c/println.c
+++ b/src/u8c/println.c
@@ -20,7 +20,7 @@
# include <u8c/println.h>
# include <u8c/seterr.h>
# include <u8c/vprint.h>
-uint_least8_t u8c_println(FILE * _fp,uint_least32_t * const _msg,...) {
+uint_least8_t u8c_println(FILE * _fp,uint_least32_t const * const _msg,...) {
assert(_fp != NULL);
va_list args;
va_start(args,_msg);
diff --git a/src/u8c/seterr.c b/src/u8c/seterr.c
index c9fec04..5796683 100644
--- a/src/u8c/seterr.c
+++ b/src/u8c/seterr.c
@@ -19,18 +19,19 @@
# include <stdint.h>
# include <stdlib.h>
# include <u8c/dbgprint.h>
+# include <u8c/freeu32.h>
# include <u8c/seterr.h>
# include <u8c/u32cp.h>
# if defined(u8c_bethrdsafe)
# include <threads.h>
# endif
-uint_least8_t u8c_seterr(uint_least32_t * const _msg) {
+uint_least8_t u8c_seterr(uint_least32_t const * const _msg) {
assert(_msg != NULL);
u8c_dbgprint(_msg);
# if defined(u8c_bethrdsafe)
mtx_lock(&u8c_errlock);
# endif
- free(u8c_err);
+ u8c_freeu32(u8c_err);
u8c_u32cp(NULL,&u8c_err,_msg);
# if defined(u8c_bethrdsafe)
mtx_unlock(&u8c_errlock);
diff --git a/src/u8c/u32cmp.c b/src/u8c/u32cmp.c
index 138eb22..3f8e405 100644
--- a/src/u8c/u32cmp.c
+++ b/src/u8c/u32cmp.c
@@ -19,7 +19,7 @@
# include <u8c/seterr.h>
# include <u8c/SIZE_C.h>
# include <u8c/u32cmp.h>
-uint_least8_t u8c_u32cmp(uint_least8_t * const _res,uint_least32_t * const _lstr,uint_least32_t * const _rstr) {
+uint_least8_t u8c_u32cmp(uint_least8_t * const _res,uint_least32_t const * const _lstr,uint_least32_t const * const _rstr) {
assert(_res != NULL);
assert(_lstr != NULL);
assert(_rstr != NULL);
diff --git a/src/u8c/u32cp.c b/src/u8c/u32cp.c
index a91226c..35e8940 100644
--- a/src/u8c/u32cp.c
+++ b/src/u8c/u32cp.c
@@ -20,7 +20,7 @@
# include <u8c/SIZE_C.h>
# include <u8c/u32cp.h>
# include <u8c/u32sz.h>
-uint_least8_t u8c_u32cp(size_t * const _sz,uint_least32_t * * const _out,uint_least32_t * const _in) {
+uint_least8_t u8c_u32cp(size_t * const _sz,uint_least32_t const * * const _out,uint_least32_t const * const _in) {
assert(_in != NULL);
size_t insz = SIZE_C(0x0);
u8c_u32sz(&insz,_in);
@@ -28,10 +28,11 @@ uint_least8_t u8c_u32cp(size_t * const _sz,uint_least32_t * * const _out,uint_le
if(_sz != NULL) {
*_sz = insz;
}
- if((*_out = calloc(sizeof(uint_least32_t),insz)) == NULL) {
+ uint_least32_t * out;
+ if((out = calloc(sizeof(uint_least32_t),insz)) == NULL) {
u8c_seterr((uint_least32_t[]){UINT32_C(0x75),UINT32_C(0x38),UINT32_C(0x63),UINT32_C(0x5F),UINT32_C(0x75),UINT32_C(0x33),UINT32_C(0x32),UINT32_C(0x63),UINT32_C(0x70),UINT32_C(0x3A),UINT32_C(0x20),UINT32_C(0x55),UINT32_C(0x6E),UINT32_C(0x61),UINT32_C(0x62),UINT32_C(0x6C),UINT32_C(0x65),UINT32_C(0x20),UINT32_C(0x74),UINT32_C(0x6F),UINT32_C(0x20),UINT32_C(0x61),UINT32_C(0x6C),UINT32_C(0x6C),UINT32_C(0x6F),UINT32_C(0x63),UINT32_C(0x61),UINT32_C(0x74),UINT32_C(0x65),UINT32_C(0x20),UINT32_C(0x72),UINT32_C(0x65),UINT32_C(0x73),UINT32_C(0x6F),UINT32_C(0x75),UINT32_C(0x72),UINT32_C(0x63),UINT32_C(0x65),UINT32_C(0x73),UINT32_C(0x2E),UINT32_C(0x0),}); /* u8c_u32cp: Unable to allocate resources. */
return UINT8_C(0x1);
- }uint_least32_t * const out = *_out;
+ }
for(register size_t n = SIZE_C(0x0);n < insz;n += SIZE_C(0x1)) {
out[n] = _in[n];
}
diff --git a/src/u8c/u32sz.c b/src/u8c/u32sz.c
index d0af24a..ca8b1be 100644
--- a/src/u8c/u32sz.c
+++ b/src/u8c/u32sz.c
@@ -19,7 +19,7 @@
# include <u8c/seterr.h>
# include <u8c/SIZE_C.h>
# include <u8c/u32sz.h>
-uint_least8_t u8c_u32sz(size_t * const _sz,uint_least32_t * const _u32) {
+uint_least8_t u8c_u32sz(size_t * const _sz,uint_least32_t const * const _u32) {
assert(_sz != NULL);
assert(_u32 != NULL);
for(register size_t n = SIZE_C(0x0);n <= SIZE_MAX;n += SIZE_C(0x1)) {
diff --git a/src/u8c/u8dec.c b/src/u8c/u8dec.c
index 98288a6..dfbfeaf 100644
--- a/src/u8c/u8dec.c
+++ b/src/u8c/u8dec.c
@@ -19,7 +19,7 @@
# include <u8c/seterr.h>
# include <u8c/u8dec.h>
# include <u8c/SIZE_C.h>
-uint_least8_t u8c_u8dec(size_t * const _sz,uint_least32_t * * const _out,uint_least8_t * const _in) {
+uint_least8_t u8c_u8dec(size_t * const _sz,uint_least32_t const * * const _out,uint_least8_t const * const _in) {
assert(_in != NULL);
register size_t insz = SIZE_C(0x0);
register size_t outsz = SIZE_C(0x1);
@@ -55,7 +55,7 @@ nottoobig:;
if(_sz != NULL) {
*_sz = outsz;
}
- *_out = calloc(sizeof(uint_least32_t),outsz);
+ uint_least32_t * out = calloc(sizeof(uint_least32_t),outsz);
for(register size_t n = SIZE_C(0x0),outn = SIZE_C(0x0);n < insz;outn += SIZE_C(0x1)) { /* Second pass: decode UTF-8. */
if(_in[n] >= UINT8_C(0xF0)) { /* Four byte. */
uint_least32_t codep = (_in[n] ^ UINT32_C(0xF0)) << UINT32_C(0x12);
@@ -66,7 +66,7 @@ nottoobig:;
n += SIZE_C(0x1);
codep += (uint_least32_t)(_in[n]) ^ SIZE_C(0x80);
n += SIZE_C(0x1);
- (*_out)[outn] = codep;
+ out[outn] = codep;
continue;
}
if(_in[n] >= UINT8_C(0xE0)) { /* Three bytes. */
@@ -76,7 +76,7 @@ nottoobig:;
n += SIZE_C(0x1);
codep += _in[n] ^ UINT32_C(0x80);
n += SIZE_C(0x1);
- (*_out)[outn] = codep;
+ out[outn] = codep;
continue;
}
if(_in[n] >= UINT8_C(0xC0)) { /* Two bytes. */
@@ -84,13 +84,14 @@ nottoobig:;
n += SIZE_C(0x1);
codep += _in[n] ^ UINT32_C(0x80);
n += SIZE_C(0x1);
- (*_out)[outn] = codep;
+ out[outn] = codep;
continue;
}
/* One byte. */
- (*_out)[outn] = (uint_least32_t)(_in[n]);
+ out[outn] = (uint_least32_t)(_in[n]);
n += SIZE_C(0x1);
continue;
}
+ *_out = out;
return UINT8_C(0x0);
}
diff --git a/src/u8c/u8enc.c b/src/u8c/u8enc.c
index 2ad8090..dda62d3 100644
--- a/src/u8c/u8enc.c
+++ b/src/u8c/u8enc.c
@@ -19,7 +19,7 @@
# include <u8c/seterr.h>
# include <u8c/u8enc.h>
# include <u8c/SIZE_C.h>
-uint_least8_t u8c_u8enc(size_t * const _sz,uint_least8_t * * const _out,uint_least32_t * const _in) {
+uint_least8_t u8c_u8enc(size_t * const _sz,uint_least8_t const * * const _out,uint_least32_t const * const _in) {
assert(_in != NULL);
size_t insz = SIZE_C(0x0); /* Size of input array (bytes). */
size_t outsz = SIZE_C(0x0); /* Size of output array /bytes). */
diff --git a/src/u8c/vfmt.c b/src/u8c/vfmt.c
index 5afc6cf..e32b6fa 100644
--- a/src/u8c/vfmt.c
+++ b/src/u8c/vfmt.c
@@ -17,7 +17,7 @@
# include <stdint.h>
# include <u8c/u32cp.h>
# include <u8c/vfmt.h>
-uint_least8_t u8c_vfmt(size_t * const _sz,uint_least32_t * * const _out,uint_least32_t * const _in,va_list _args) {
+uint_least8_t u8c_vfmt(size_t * const _sz,uint_least32_t const * * const _out,uint_least32_t const * const _in,va_list _args) {
/* To be added. */
return u8c_u32cp(_sz,_out,_in);
}
diff --git a/src/u8c/vprint.c b/src/u8c/vprint.c
index a731cb2..2e418ca 100644
--- a/src/u8c/vprint.c
+++ b/src/u8c/vprint.c
@@ -18,24 +18,26 @@
# include <stdint.h>
# include <stdio.h>
# include <stdlib.h>
+# include <u8c/freeu32.h>
+# include <u8c/freeu8.h>
# include <u8c/seterr.h>
# include <u8c/u8enc.h>
# include <u8c/SIZE_C.h>
# include <u8c/vfmt.h>
# include <u8c/vprint.h>
-uint_least8_t u8c_vprint(FILE * _fp,uint_least32_t * const _msg,va_list _args) {
+uint_least8_t u8c_vprint(FILE * _fp,uint_least32_t const * const _msg,va_list _args) {
assert(_msg != NULL);
- uint_least32_t * str0 = NULL;
+ uint_least32_t const * str0 = NULL;
u8c_vfmt(NULL,&str0,_msg,_args);
size_t str1sz = SIZE_C(0x0);
- uint_least8_t * str1 = NULL;
+ uint_least8_t const * str1 = NULL;
u8c_u8enc(&str1sz,&str1,str0);
assert(str1sz > SIZE_C(0x0));
if(fwrite(str1,sizeof(uint_least8_t),str1sz - SIZE_C(0x1),_fp) < str1sz - SIZE_C(0x1)) {
u8c_seterr((uint_least32_t[]){UINT32_C(0x75),UINT32_C(0x38),UINT32_C(0x63),UINT32_C(0x5F),UINT32_C(0x76),UINT32_C(0x70),UINT32_C(0x72),UINT32_C(0x69),UINT32_C(0x6E),UINT32_C(0x74),UINT32_C(0x3A),UINT32_C(0x20),UINT32_C(0x66),UINT32_C(0x77),UINT32_C(0x72),UINT32_C(0x69),UINT32_C(0x74),UINT32_C(0x65),UINT32_C(0x3A),UINT32_C(0x20),UINT32_C(0x55),UINT32_C(0x6E),UINT32_C(0x61),UINT32_C(0x62),UINT32_C(0x6C),UINT32_C(0x65),UINT32_C(0x20),UINT32_C(0x74),UINT32_C(0x6F),UINT32_C(0x20),UINT32_C(0x77),UINT32_C(0x72),UINT32_C(0x69),UINT32_C(0x74),UINT32_C(0x65),UINT32_C(0x20),UINT32_C(0x74),UINT32_C(0x6F),UINT32_C(0x20),UINT32_C(0x73),UINT32_C(0x74),UINT32_C(0x64),UINT32_C(0x6F),UINT32_C(0x75),UINT32_C(0x74),UINT32_C(0x2E),UINT32_C(0x0),}); /* u8c_vprint: fwrite: Unable to write to stdout. */
return UINT8_C(0x1);
}
- free(str0);
- free(str1);
+ u8c_freeu32(str0);
+ u8c_freeu8(str1);
return UINT8_C(0x0);
}