hrev47249 adds 1 changeset to branch 'master' old head: 5710ad967d7ba37ced59b5c80f0dde001e5417cd new head: 5e36a367d7edc677c0183c7a6fc6b6ec5bb40cf1 overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=5e36a36+%5E5710ad9 ---------------------------------------------------------------------------- 5e36a36: Convert strdup.c to C++. [ Adrien Destugues <pulkomandy@xxxxxxxxxxxxx> ] ---------------------------------------------------------------------------- Revision: hrev47249 Commit: 5e36a367d7edc677c0183c7a6fc6b6ec5bb40cf1 URL: http://cgit.haiku-os.org/haiku/commit/?id=5e36a36 Author: Adrien Destugues <pulkomandy@xxxxxxxxxxxxx> Date: Fri May 23 16:30:26 2014 UTC ---------------------------------------------------------------------------- 4 files changed, 9 insertions(+), 32 deletions(-) src/system/boot/Jamfile | 2 +- src/system/kernel/lib/Jamfile | 2 +- src/system/libroot/posix/string/Jamfile | 8 +++++++- src/system/libroot/posix/string/strdup.c | 29 ---------------------------- ---------------------------------------------------------------------------- diff --git a/src/system/boot/Jamfile b/src/system/boot/Jamfile index 3c704f9..46aecb6 100644 --- a/src/system/boot/Jamfile +++ b/src/system/boot/Jamfile @@ -21,7 +21,7 @@ BootMergeObject boot_libroot.o : memchr.c memcmp.c memmove.c - strdup.c + strdup.cpp strndup.cpp strlen.cpp strnlen.cpp diff --git a/src/system/kernel/lib/Jamfile b/src/system/kernel/lib/Jamfile index bcaa986..5d0319d 100644 --- a/src/system/kernel/lib/Jamfile +++ b/src/system/kernel/lib/Jamfile @@ -107,7 +107,7 @@ KernelMergeObject kernel_lib_posix.o : strcmp.c strcpy.c strcspn.c - strdup.c + strdup.cpp strerror.c strlcat.c strlcpy.c diff --git a/src/system/libroot/posix/string/Jamfile b/src/system/libroot/posix/string/Jamfile index a8d53bc..609c0fd 100644 --- a/src/system/libroot/posix/string/Jamfile +++ b/src/system/libroot/posix/string/Jamfile @@ -5,6 +5,12 @@ UsePrivateHeaders [ FDirName libroot locale ] ; + +# Our versions of strdup and strndup check for NULL parameters (for BeOS +# compatibility), but GCC optimizes this away as its builtins don't handle +# it. +C++FLAGS += -fno-builtin-strdup -fno-builtin-strndup ; + local architectureObject ; for architectureObject in [ MultiArchSubDirSetup ] { on $(architectureObject) { @@ -29,7 +35,7 @@ for architectureObject in [ MultiArchSubDirSetup ] { strcoll.cpp strcpy.c strcspn.c - strdup.c + strdup.cpp strerror.c strlcat.c strlcpy.c diff --git a/src/system/libroot/posix/string/strdup.c b/src/system/libroot/posix/string/strdup.c deleted file mode 100644 index a4306f0..0000000 --- a/src/system/libroot/posix/string/strdup.c +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2003-2007, Axel Dörfler, axeld@xxxxxxxxxxxxxxxx. All rights reserved. - * Distributed under the terms of the MIT License. - */ - - -#include <string.h> -#include <stdlib.h> - - -char* -strdup(const char *string) -{ - char* copied; - size_t length; - - // unlike the standard strdup() function, the BeOS implementation - // handles NULL strings gracefully - if (string == NULL) - return NULL; - - length = strlen(string) + 1; - - if ((copied = (char *)malloc(length)) == NULL) - return NULL; - - memcpy(copied, string, length); - return copied; -}