minor fixes in xalloc and rbtree.
rbtree didn't include string.h xalloc uses strdup that is not needed.
This commit is contained in:
parent
f3158fb988
commit
d420a86372
2 changed files with 9 additions and 5 deletions
|
|
@ -10,7 +10,7 @@
|
||||||
* Based on the work of Julienne Walker's rbtree implementation
|
* Based on the work of Julienne Walker's rbtree implementation
|
||||||
* http://www.eternallyconfuzzled.com/tuts/datastructures/jsw_tut_rbtree.aspx
|
* http://www.eternallyconfuzzled.com/tuts/datastructures/jsw_tut_rbtree.aspx
|
||||||
*/
|
*/
|
||||||
|
#include <string.h>
|
||||||
#include "xalloc.h"
|
#include "xalloc.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "rbtree.h"
|
#include "rbtree.h"
|
||||||
|
|
|
||||||
12
src/xalloc.c
12
src/xalloc.c
|
|
@ -68,9 +68,12 @@ char* xstrdup(const char *s) {
|
||||||
|
|
||||||
CHECK_INPUT(s);
|
CHECK_INPUT(s);
|
||||||
|
|
||||||
char *c = strdup(s);
|
size_t len = strlen(s) + 1;
|
||||||
CHECK(c);
|
char *dest = xmalloc(len);
|
||||||
return c;
|
|
||||||
|
CHECK(dest);
|
||||||
|
memcpy(dest, s, len);
|
||||||
|
return dest;
|
||||||
bail:
|
bail:
|
||||||
die_errno("xstrdup");
|
die_errno("xstrdup");
|
||||||
}
|
}
|
||||||
|
|
@ -79,7 +82,8 @@ void* xmemdup(const void *src, size_t size) {
|
||||||
|
|
||||||
CHECK_INPUT(src);
|
CHECK_INPUT(src);
|
||||||
|
|
||||||
void *dest = xmalloc(size);
|
void *dest = malloc(size);
|
||||||
|
CHECK(dest);
|
||||||
memcpy(dest, src, size);
|
memcpy(dest, src, size);
|
||||||
return dest;
|
return dest;
|
||||||
bail:
|
bail:
|
||||||
|
|
|
||||||
Reference in a new issue