Browse Source

Added strdup()

tags/v0.9.3
Michael Brown 17 years ago
parent
commit
496563071d
2 changed files with 11 additions and 2 deletions
  1. 10
    2
      src/core/string.c
  2. 1
    0
      src/include/string.h

+ 10
- 2
src/core/string.c View File

@@ -21,8 +21,9 @@
21 21
  *    reentrant and should be faster). Use only strsep() in new code, please.
22 22
  */
23 23
  
24
-#include "etherboot.h"
25
-
24
+#include <stdint.h>
25
+#include <stdlib.h>
26
+#include <string.h>
26 27
 
27 28
 /* *** FROM string.c *** */
28 29
 
@@ -538,3 +539,10 @@ void * memchr(const void *s, int c, size_t n)
538 539
 }
539 540
 
540 541
 #endif
542
+
543
+char * strdup(const char *s) {
544
+	char *new = malloc(strlen(s)+1);
545
+	if (new)
546
+		strcpy(new,s);
547
+	return new;
548
+}

+ 1
- 0
src/include/string.h View File

@@ -66,5 +66,6 @@ int __attribute__ (( pure )) memcmp(const void * cs,const void * ct,
66 66
 void * memscan(void * addr, int c, size_t size);
67 67
 char * strstr(const char * s1,const char * s2);
68 68
 void * memchr(const void *s, int c, size_t n);
69
+char * strdup(const char *s);
69 70
 
70 71
 #endif /* ETHERBOOT_STRING */

Loading…
Cancel
Save