Archived
1
0
Fork 0

minor fixes in xalloc and rbtree.

rbtree didn't include string.h
xalloc uses strdup that is not needed.
This commit is contained in:
Henrik Hautakoski 2010-10-24 13:54:40 +02:00
parent f3158fb988
commit d420a86372
2 changed files with 9 additions and 5 deletions

View file

@ -10,7 +10,7 @@
* Based on the work of Julienne Walker's rbtree implementation
* http://www.eternallyconfuzzled.com/tuts/datastructures/jsw_tut_rbtree.aspx
*/
#include <string.h>
#include "xalloc.h"
#include "debug.h"
#include "rbtree.h"

View file

@ -68,9 +68,12 @@ char* xstrdup(const char *s) {
CHECK_INPUT(s);
char *c = strdup(s);
CHECK(c);
return c;
size_t len = strlen(s) + 1;
char *dest = xmalloc(len);
CHECK(dest);
memcpy(dest, s, len);
return dest;
bail:
die_errno("xstrdup");
}
@ -79,7 +82,8 @@ void* xmemdup(const void *src, size_t size) {
CHECK_INPUT(src);
void *dest = xmalloc(size);
void *dest = malloc(size);
CHECK(dest);
memcpy(dest, src, size);
return dest;
bail: