/* * This file is part of corelibs. (https://git.redxen.eu/corelibs) * Copyright (c) 2021 Alex-David Denes * * corelibs is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * corelibs is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with corelibs. If not, see . */ #ifndef CORELIBS_GUARD_LLIST #define CORELIBS_GUARD_LLIST typedef struct llist_t llist_t; typedef signed short int llist_err; struct corelibs_llist_interface { llist_err (*const create)(void* content, void (*const free_function)(void*), llist_t** save); llist_err (*const link)(llist_t* element_a, llist_t* element_b); llist_err (*const free)(llist_t* element); const struct { llist_err (*const cont)(llist_t* element, void* content); llist_err (*const free)(llist_t* element, void (*const free_function)(void*)); } set; const struct { llist_err (*const prev)(const llist_t* element, llist_t** save); llist_err (*const next)(const llist_t* element, llist_t** save); llist_err (*const cont)(const llist_t* element, void** save); } get; const struct { const llist_err ok, // No error unknown, // Unknown error undef; // Fetched element is undefined const struct { const llist_err null, // NULL address was passed alloc; // Allocation failed } mem; } err; }; extern const struct corelibs_llist_interface llist; #endif /* CORELIBS_GUARD_LLIST */