/** 
 * \file linearlist.c
 * \brief linearlist source file
 * \details File contains functions definitions for linear list (type LIFO)
 *
 * \author Juraj Golej
 * \version 1.0
 */

#include "linearlist.h"

bool linearlist_delete(struct linearlist* const list, void *const node)
{
	if(!list || !node || !list->head) {
		return false;
	}

	if(list->head == node) {
		list->head = list->head->next;
		((struct linearlist_node*)node)->next = NULL;
		return true;
	} 
	else {
		struct linearlist_node *actual = list->head;

		while(actual && actual->next != node) {
			actual = actual->next;
		}
		if(actual) {
			actual->next = ((struct linearlist_node*)node)->next;
			return true;
		}
	}

	return false;
}