void insert(u32 x, u32 y, u32 f){ if (in_list(x,y,f) == 1){ return; } else{ olnode* newnode = calloc(1,sizeof(newnode)); newnode->x = x/8; newnode->y = y/8; newnode->fvalue = f; olnode* temp = head; while(temp != NULL){ printf("%d\n",temp->fvalue); if(is_smaller(newnode,temp) == 1){ if(temp->parent == NULL){ printf("NOOOOOOOOOOOOOOO\n"); newnode->next = temp; newnode->parent = NULL; temp->parent = newnode; head = newnode; return; } else{ printf("HELLO\n"); newnode->parent = temp->parent; newnode->parent->next = newnode; temp->parent = newnode; newnode->next = temp; return; } } else if(temp->next == NULL){ // end of list temp->next = newnode; newnode->parent = temp; newnode->next = NULL; printf("%d\n",temp->fvalue); printf("HELLO\n"); return; } temp = temp->next; } } }