From c7187ce599df0f6ff1e516b94aa22312dc43e179 Mon Sep 17 00:00:00 2001 From: Patrick Williams Date: Fri, 5 Sep 2014 15:12:20 -0500 Subject: Add strdup. Change-Id: Ib136e5f4200e6cb439c3bbef83de94229f2dbebe Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/13248 Tested-by: Jenkins Server Reviewed-by: Brian Silver Reviewed-by: STEPHEN M. CPREK Reviewed-by: A. Patrick Williams III --- src/lib/string.C | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/lib/string.C') diff --git a/src/lib/string.C b/src/lib/string.C index 7a4d1df6f..9acc418e7 100644 --- a/src/lib/string.C +++ b/src/lib/string.C @@ -5,7 +5,9 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* COPYRIGHT International Business Machines Corp. 2011,2014 */ +/* Contributors Listed Below - COPYRIGHT 2011,2014 */ +/* [+] International Business Machines Corp. */ +/* */ /* */ /* Licensed under the Apache License, Version 2.0 (the "License"); */ /* you may not use this file except in compliance with the License. */ @@ -21,6 +23,7 @@ /* */ /* IBM_PROLOG_END_TAG */ #include +#include extern "C" void *memset(void *vdest, int ch, size_t len) { @@ -281,3 +284,8 @@ extern "C" char* strchr(const char* s, int c) if (*s == c) return (char*)s; return NULL; } + +char* strdup(const char* s) +{ + return strcpy(static_cast(malloc(strlen(s)+1)), s); +} -- cgit v1.2.1