#include <stddef.h>
#include <string.h>
+#include <lib-lib/mem.h>
+
#include "list.h"
#include "mem.h"
if (del)
for (i = 0; i < (*l)->length; i++)
del (&(*l)->data[i]);
- mem_free(&(*l)->data);
- mem_free(l);
+ p_delete(&(*l)->data);
+ p_delete(l);
}
void list_push_back (list2_t** l, void* p) {
return (p);
}
-list2_t* list_cpy (list2_t* l) {
- list2_t* ret = NULL;
- if (list_empty(l))
- return (NULL);
- ret = list_new ();
- ret->length = l->length;
- ret->data = mem_malloc (l->length*sizeof(void*));
- memcpy (ret->data, l->data, l->length*sizeof(void*));
- return (ret);
+list2_t *list_cpy(list2_t *l) {
+ list2_t* ret = NULL;
+ if (list_empty(l))
+ return NULL;
+ ret = list_new();
+ ret->length = l->length;
+ ret->data = p_dup(l->data, l->length);
+ return ret;
}
list2_t* list_dup (list2_t* l, void* (*dup) (void*)) {
return (NULL);
ret = list_new ();
ret->length = l->length;
- ret->data = mem_malloc (l->length*sizeof(void*));
+ ret->data = p_new(void*, l->length);
for (i = 0; i < l->length; i++)
ret->data[i] = dup (l->data[i]);
return (ret);
for (p = strtok (tmp, delim); p; p = strtok (NULL, delim)) {
list_push_back (&ret, str_dup (p));
}
- mem_free (&tmp);
+ p_delete(&tmp);
return (ret);
}