Commit 36e733cb authored by Lenitra's avatar Lenitra
Browse files

push

parent 828bf1d1
Loading
Loading
Loading
Loading
+7 −5
Changes for src/list.c: 7 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ int list_is_empty(list_t l){

list_t list_push(list_t l, void* x){
  // add x to the end of l
  list_t c = malloc(sizeof(l));
  c -> val = x;
  if (list_is_empty(l)){
    c -> id = 0;
@@ -80,11 +81,12 @@ void* list_in(list_t l, void* x, int (*eq)(void*, void*)){
}

unsigned long int list_len(list_t l){
  unsigned long int len = 0;
  while(!list_is_empty(l)){
    len++;
    l = l->next;
 if (list_is_empty(l)){
   return 0;
 }
  return len;
 else {
   return l->id + 1;
 }
 
}