diff options
| author | Michael Brown | 2006-12-08 01:34:47 +0100 |
|---|---|---|
| committer | Michael Brown | 2006-12-08 01:34:47 +0100 |
| commit | 496563071d22166522a4ec9887357dde00d07fdc (patch) | |
| tree | e13aa34801f29413b766367f8d9b6e1c74850c3a | |
| parent | Added missing prototype (diff) | |
| download | ipxe-496563071d22166522a4ec9887357dde00d07fdc.tar.gz ipxe-496563071d22166522a4ec9887357dde00d07fdc.tar.xz ipxe-496563071d22166522a4ec9887357dde00d07fdc.zip | |
Added strdup()
| -rw-r--r-- | src/core/string.c | 12 | ||||
| -rw-r--r-- | src/include/string.h | 1 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/core/string.c b/src/core/string.c index 856f955b6..da35e208b 100644 --- a/src/core/string.c +++ b/src/core/string.c @@ -21,8 +21,9 @@ * reentrant and should be faster). Use only strsep() in new code, please. */ -#include "etherboot.h" - +#include <stdint.h> +#include <stdlib.h> +#include <string.h> /* *** FROM string.c *** */ @@ -538,3 +539,10 @@ void * memchr(const void *s, int c, size_t n) } #endif + +char * strdup(const char *s) { + char *new = malloc(strlen(s)+1); + if (new) + strcpy(new,s); + return new; +} diff --git a/src/include/string.h b/src/include/string.h index 8ada05a0f..a6f3e71b9 100644 --- a/src/include/string.h +++ b/src/include/string.h @@ -66,5 +66,6 @@ int __attribute__ (( pure )) memcmp(const void * cs,const void * ct, void * memscan(void * addr, int c, size_t size); char * strstr(const char * s1,const char * s2); void * memchr(const void *s, int c, size_t n); +char * strdup(const char *s); #endif /* ETHERBOOT_STRING */ |
