using why2-memory in why2-llist
This commit is contained in:
parent
994a2a8c4f
commit
98cc5b83b8
@ -22,12 +22,14 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <why2/memory.h>
|
||||||
|
|
||||||
void why2_list_push(why2_list_t *list, void *value, unsigned long size)
|
void why2_list_push(why2_list_t *list, void *value, unsigned long size)
|
||||||
{
|
{
|
||||||
//CREATE NODE
|
//CREATE NODE
|
||||||
why2_node_t *head = list -> head;
|
why2_node_t *head = list -> head;
|
||||||
why2_node_t *new_node = malloc(sizeof(why2_node_t));
|
why2_node_t *new_node = why2_malloc(sizeof(why2_node_t));
|
||||||
new_node -> value = malloc(size);
|
new_node -> value = why2_malloc(size);
|
||||||
why2_node_t *buffer = head;
|
why2_node_t *buffer = head;
|
||||||
|
|
||||||
//INSERT DATA
|
//INSERT DATA
|
||||||
@ -55,8 +57,8 @@ void why2_list_push_at(why2_list_t *list, unsigned long index, void *value, unsi
|
|||||||
{
|
{
|
||||||
//CREATE NODE
|
//CREATE NODE
|
||||||
why2_node_t *head = list -> head;
|
why2_node_t *head = list -> head;
|
||||||
why2_node_t *new_node = malloc(sizeof(why2_node_t));
|
why2_node_t *new_node = why2_malloc(sizeof(why2_node_t));
|
||||||
new_node -> value = malloc(size);
|
new_node -> value = why2_malloc(size);
|
||||||
|
|
||||||
//INSERT DATA
|
//INSERT DATA
|
||||||
memcpy(new_node -> value, value, size);
|
memcpy(new_node -> value, value, size);
|
||||||
@ -111,8 +113,8 @@ void why2_list_remove(why2_list_t *list, why2_node_t *node)
|
|||||||
list -> head = head;
|
list -> head = head;
|
||||||
|
|
||||||
//DEALLOCATION
|
//DEALLOCATION
|
||||||
free(node -> value);
|
why2_deallocate(node -> value);
|
||||||
free(node);
|
why2_deallocate(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
void why2_list_remove_back(why2_list_t *list)
|
void why2_list_remove_back(why2_list_t *list)
|
||||||
@ -137,8 +139,8 @@ void why2_list_remove_back(why2_list_t *list)
|
|||||||
buffer -> next = NULL; //UNLINK
|
buffer -> next = NULL; //UNLINK
|
||||||
}
|
}
|
||||||
|
|
||||||
free(deallocating_node -> value);
|
why2_deallocate(deallocating_node -> value);
|
||||||
free(deallocating_node);
|
why2_deallocate(deallocating_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
why2_node_t *why2_list_find(why2_list_t *list, void *value)
|
why2_node_t *why2_list_find(why2_list_t *list, void *value)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user