diff options
Diffstat (limited to 'src/u8c/u32cp.c')
-rw-r--r-- | src/u8c/u32cp.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/u8c/u32cp.c b/src/u8c/u32cp.c index 35e8940..979686f 100644 --- a/src/u8c/u32cp.c +++ b/src/u8c/u32cp.c @@ -14,28 +14,32 @@ If not, see <https://www.gnu.org/licenses/>. */ # include <assert.h> -# include <stdint.h> +# include <stdbool.h> # include <stdlib.h> -# include <u8c/seterr.h> # include <u8c/SIZE_C.h> +# include <u8c/seterr.h> +# include <u8c/u32alloc.h> # include <u8c/u32cp.h> +# include <u8c/u32free.h> # include <u8c/u32sz.h> -uint_least8_t u8c_u32cp(size_t * const _sz,uint_least32_t const * * const _out,uint_least32_t const * const _in) { +bool u8c_u32cp(size_t * const _sz,char32_t const * * const _out,char32_t const * const _in) { + assert(_out != NULL); assert(_in != NULL); + if(*_out != NULL) { + u8c_u32free(&*_out); + } size_t insz = SIZE_C(0x0); u8c_u32sz(&insz,_in); - assert(insz > SIZE_C(0x0)); if(_sz != NULL) { *_sz = insz; } - 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 * out = NULL; + if(u8c_u32alloc(&out,insz + SIZE_C(0x1))) { + return false; } for(register size_t n = SIZE_C(0x0);n < insz;n += SIZE_C(0x1)) { out[n] = _in[n]; } *_out = out; - return UINT8_C(0x0); + return false; } |