Added strdup()
This commit is contained in:
parent
1e4a838f55
commit
496563071d
|
@ -21,8 +21,9 @@
|
||||||
* reentrant and should be faster). Use only strsep() in new code, please.
|
* 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 *** */
|
/* *** FROM string.c *** */
|
||||||
|
|
||||||
|
@ -538,3 +539,10 @@ void * memchr(const void *s, int c, size_t n)
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
char * strdup(const char *s) {
|
||||||
|
char *new = malloc(strlen(s)+1);
|
||||||
|
if (new)
|
||||||
|
strcpy(new,s);
|
||||||
|
return new;
|
||||||
|
}
|
||||||
|
|
|
@ -66,5 +66,6 @@ int __attribute__ (( pure )) memcmp(const void * cs,const void * ct,
|
||||||
void * memscan(void * addr, int c, size_t size);
|
void * memscan(void * addr, int c, size_t size);
|
||||||
char * strstr(const char * s1,const char * s2);
|
char * strstr(const char * s1,const char * s2);
|
||||||
void * memchr(const void *s, int c, size_t n);
|
void * memchr(const void *s, int c, size_t n);
|
||||||
|
char * strdup(const char *s);
|
||||||
|
|
||||||
#endif /* ETHERBOOT_STRING */
|
#endif /* ETHERBOOT_STRING */
|
||||||
|
|
Reference in New Issue