1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-29 11:41:21 +03:00
* string/bits/string2.h (__strdup): Cast parameters to calloc to
	avoid warning with -Wconversion.
	(__strndup): Likewise.
	Patch to 50% by Christian Iseli <christian.iseli@licr.org>.
This commit is contained in:
Ulrich Drepper
2007-10-05 21:21:08 +00:00
parent 3e6ce4d77e
commit a83b5649c5
2 changed files with 8 additions and 2 deletions

View File

@ -1305,7 +1305,7 @@ extern char *__strdup (__const char *__string) __THROW __attribute_malloc__;
# define __strdup(s) \
(__extension__ (__builtin_constant_p (s) && __string2_1bptr_p (s) \
? (((__const char *) (s))[0] == '\0' \
? (char *) calloc (1, 1) \
? (char *) calloc ((size_t) 1, (size_t) 1) \
: ({ size_t __len = strlen (s) + 1; \
char *__retval = (char *) malloc (__len); \
if (__retval != NULL) \
@ -1325,7 +1325,7 @@ extern char *__strndup (__const char *__string, size_t __n)
# define __strndup(s, n) \
(__extension__ (__builtin_constant_p (s) && __string2_1bptr_p (s) \
? (((__const char *) (s))[0] == '\0' \
? (char *) calloc (1, 1) \
? (char *) calloc ((size_t) 1, (size_t) 1) \
: ({ size_t __len = strlen (s) + 1; \
size_t __n = (n); \
char *__retval; \