From 6fc929b1384a97dd7922af731667dd2539819a49 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 19 Nov 2009 10:21:05 -0800 Subject: Use unsigned char * as allocator return value. --- ChangeLog | 10 ++++++++++ lib.c | 4 ++-- lib.h | 4 ++-- utf8.c | 2 +- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index a1c7c3ba..4c74ebef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2009-11-19 Kaz Kylheku + + Use unsigned char * as allocator return value. + + * lib.c (chk_malloc, chk_realloc): Return unsigned char *. + + * lib.c (chk_malloc, chk_realloc): Declarations updated. + + * utf8 (utf8_dup_to_uc): Remove cast to unsigned char *. + 2009-11-18 Kaz Kylheku Following-up on diagnostics obtained by running code through C++ diff --git a/lib.c b/lib.c index f2451ec1..ab1447fa 100644 --- a/lib.c +++ b/lib.c @@ -518,7 +518,7 @@ static obj_t *equal_tramp(obj_t *env, obj_t *left, obj_t *right) return equal(left, right); } -char *chk_malloc(size_t size) +unsigned char *chk_malloc(size_t size) { char *ptr = malloc(size); if (size && ptr == 0) @@ -526,7 +526,7 @@ char *chk_malloc(size_t size) return ptr; } -char *chk_realloc(void *old, size_t size) +unsigned char *chk_realloc(void *old, size_t size) { char *newptr = realloc(old, size); if (size != 0 && newptr == 0) diff --git a/lib.h b/lib.h index a11888cc..f0ee023c 100644 --- a/lib.h +++ b/lib.h @@ -222,8 +222,8 @@ obj_t *none_satisfy(obj_t *list, obj_t *pred, obj_t *key); long c_num(obj_t *num); obj_t *nump(obj_t *num); obj_t *equal(obj_t *left, obj_t *right); -char *chk_malloc(size_t size); -char *chk_realloc(void *, size_t size); +unsigned char *chk_malloc(size_t size); +unsigned char *chk_realloc(void *, size_t size); wchar_t *chk_strdup(const wchar_t *str); obj_t *cons(obj_t *car, obj_t *cdr); obj_t *list(obj_t *first, ...); /* terminated by nao */ diff --git a/utf8.c b/utf8.c index 46b1feae..56f533a2 100644 --- a/utf8.c +++ b/utf8.c @@ -169,7 +169,7 @@ wchar_t *utf8_dup_from(const char *str) unsigned char *utf8_dup_to_uc(const wchar_t *wstr) { size_t nbyte = utf8_to_uc(0, wstr); - unsigned char *str = (unsigned char *) chk_malloc(nbyte); + unsigned char *str = chk_malloc(nbyte); utf8_to_uc(str, wstr); return str; } -- cgit v1.2.3