diff options
author | Mattias Andrée <maandree@kth.se> | 2024-08-18 09:43:16 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2024-08-18 09:43:16 +0200 |
commit | 715b59e5002b971a987c3c8a2e1b3e61d80388f7 (patch) | |
tree | aa64aa9fed94388056432f0f4a2180d5c03523fd /test.c | |
parent | Add @since for definitions added in version 1.0 and 1.1 (diff) | |
parent | Fix tests and libsimple_arraycpy and libsimple_arraymove (diff) | |
download | libsimple-715b59e5002b971a987c3c8a2e1b3e61d80388f7.tar.gz libsimple-715b59e5002b971a987c3c8a2e1b3e61d80388f7.tar.bz2 libsimple-715b59e5002b971a987c3c8a2e1b3e61d80388f7.tar.xz |
Merge tag '1.2' into since
Version 1.2
Diffstat (limited to '')
-rw-r--r-- | test.c | 34 |
1 files changed, 33 insertions, 1 deletions
@@ -229,11 +229,43 @@ strndup(const char *s, size_t n) } +#if 0 void * memdup(const void *s, size_t size) { return libsimple_memdup(s, size); } +#endif + + +wchar_t * +wcsdup(const wchar_t *s) +{ + wchar_t *r; + size_t n = wcslen(s) + 1; + if (n > SIZE_MAX / sizeof(wchar_t)) { + errno = ENOMEM; + return NULL; + } + r = malloc(n * sizeof(wchar_t)); + return r ? wcscpy(r, s) : r; +} + + +#if 0 +wchar_t * +wcsndup(const wchar_t *s, size_t n) +{ + return libsimple_wcsndup(s, n); +} + + +wchar_t * +wmemdup(const wchar_t *s, size_t n) +{ + return libsimple_wmemdup(s, n); +} +#endif void @@ -255,7 +287,7 @@ memset(void *s, int c, size_t n) { char *str = s; struct allocinfo *info; - if (just_alloced && s == just_alloced) { + if (s == just_alloced && just_alloced && !c) { info = get_allocinfo(s); info->zeroed = MAX(info->zeroed, n); } |