implemented why2_list_t in why2_list_push
This commit is contained in:
parent
ff2ec4078d
commit
97345b52c3
@ -22,19 +22,20 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
void why2_list_push(why2_node_t *llist_head, void *value)
|
void why2_list_push(why2_list_t *list, void *value)
|
||||||
{
|
{
|
||||||
//CREATE NODE
|
//CREATE NODE
|
||||||
|
why2_node_t *head = list -> head;
|
||||||
why2_node_t *new_node = malloc(sizeof(why2_node_t));
|
why2_node_t *new_node = malloc(sizeof(why2_node_t));
|
||||||
why2_node_t *buffer = llist_head;
|
why2_node_t *buffer = head;
|
||||||
|
|
||||||
//INSERT DATA
|
//INSERT DATA
|
||||||
new_node -> value = value;
|
new_node -> value = value;
|
||||||
new_node -> next = NULL;
|
new_node -> next = NULL;
|
||||||
|
|
||||||
if (llist_head == NULL) //INIT LIST
|
if (head == NULL) //INIT LIST
|
||||||
{
|
{
|
||||||
llist_head = new_node;
|
head = new_node;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
while (buffer -> next != NULL) buffer = buffer -> next; //GET TO THE END OF LIST
|
while (buffer -> next != NULL) buffer = buffer -> next; //GET TO THE END OF LIST
|
||||||
|
Loading…
x
Reference in New Issue
Block a user