diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-09-22 06:35:07 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-09-22 06:35:07 -0700 |
commit | 1f57463ee7f381bd527f2b8ea1638ae8a3916834 (patch) | |
tree | e3a640cbd046068391101f99a0efb61549d3e260 /lib.h | |
parent | 206f432b1b5811c99ecf5f14a914de8da37277c0 (diff) | |
download | txr-1f57463ee7f381bd527f2b8ea1638ae8a3916834.tar.gz txr-1f57463ee7f381bd527f2b8ea1638ae8a3916834.tar.bz2 txr-1f57463ee7f381bd527f2b8ea1638ae8a3916834.zip |
Introduce chk_wmalloc function.
Two-fold benefit. Simplifies code which allocates wchar_t
arrays. Provides overflow check for the multiplication.
* lib.c (chk_wmalloc): New function.
(chk_strdup, mkstring, mkustring, upcase_str, downcase_str,
sub_str, cat_str, trim_str): Use chk_wmalloc.
* lib.h (chk_wmalloc): Declared.
* stream.c (make_string_output_stream): Use chk_wmalloc.
* utf8.c (utf8_dup_from_uc, utf8_dup_from): Likewise.
Diffstat (limited to 'lib.h')
-rw-r--r-- | lib.h | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -535,6 +535,7 @@ mem_t *chk_calloc(size_t n, size_t size); mem_t *chk_realloc(mem_t *, size_t size); mem_t *chk_grow_vec(mem_t *old, size_t oldelems, size_t newelems, size_t elsize); +wchar_t *chk_wmalloc(size_t nwchar); wchar_t *chk_strdup(const wchar_t *str); char *chk_strdup_utf8(const char *str); val cons(val car, val cdr); |