OS1/movies/node.c

47 lines
644 B
C

#include "node.h"
void append_node(struct node* head, struct node* node_app) {
if(!head) {
head = node_app;
return;
}
struct node* temp = head;
while(temp->node != NULL) {
temp = temp->node;
}
temp->node = node_app;
}
struct node* appendv_node(struct node* head, void* data) {
struct node* node = malloc(sizeof(struct node));
node->data = data;
node->node = NULL;
append_node(head, node);
return node;
}
int count_nodes(struct node* head) {
int num = 1;
if(!head)
return -1;
struct node* temp = head;
while(temp->node) {
temp = temp->node;
num++;
}
return num;
}