Project

General

Profile

Feature #388 ยป 0062-genlist-Replace-parameter-checking-fc_asserts-with-n.patch

Marko Lindqvist, 04/19/2024 08:44 PM

View differences:

utility/genlist.c
****************************************************************************/
int genlist_size(const struct genlist *pgenlist)
{
fc_assert_ret_val(pgenlist != nullptr, 0);
return pgenlist->nelements;
}
......
****************************************************************************/
struct genlist_link *genlist_link_get(const struct genlist *pgenlist, int idx)
{
fc_assert_ret_val(pgenlist != nullptr, nullptr);
return genlist_link_at_pos(pgenlist, idx);
}
......
****************************************************************************/
void genlist_clear(struct genlist *pgenlist)
{
fc_assert_ret(pgenlist != nullptr);
if (0 < pgenlist->nelements) {
genlist_free_fn_t free_data_func = pgenlist->free_data_func;
struct genlist_link *plink = pgenlist->head_link, *plink2;
......
void genlist_unique_full(struct genlist *pgenlist,
genlist_comp_fn_t comp_data_func)
{
fc_assert_ret(pgenlist != nullptr);
if (2 <= pgenlist->nelements) {
struct genlist_link *plink = pgenlist->head_link, *plink2;
......
{
struct genlist_link *plink;
fc_assert_ret_val(pgenlist != nullptr, FALSE);
for (plink = pgenlist->head_link; plink != nullptr; plink = plink->next) {
if (plink->dataptr == punlink) {
genlist_link_destroy(pgenlist, plink);
......
struct genlist_link *plink;
int count = 0;
fc_assert_ret_val(pgenlist != nullptr, 0);
for (plink = pgenlist->head_link; plink != nullptr;) {
if (plink->dataptr == punlink) {
struct genlist_link *pnext = plink->next;
......
bool genlist_remove_if(struct genlist *pgenlist,
genlist_cond_fn_t cond_data_func)
{
fc_assert_ret_val(pgenlist != nullptr, FALSE);
if (cond_data_func != nullptr) {
struct genlist_link *plink = pgenlist->head_link;
......
int genlist_remove_all_if(struct genlist *pgenlist,
genlist_cond_fn_t cond_data_func)
{
fc_assert_ret_val(pgenlist != nullptr, 0);
if (cond_data_func != nullptr) {
struct genlist_link *plink = pgenlist->head_link;
int count = 0;
......
****************************************************************************/
void genlist_erase(struct genlist *pgenlist, struct genlist_link *plink)
{
fc_assert_ret(pgenlist != nullptr);
if (plink != nullptr) {
genlist_link_destroy(pgenlist, plink);
}
......
****************************************************************************/
void genlist_pop_front(struct genlist *pgenlist)
{
fc_assert_ret(pgenlist != nullptr);
if (pgenlist->head_link != nullptr) {
genlist_link_destroy(pgenlist, pgenlist->head_link);
}
......
****************************************************************************/
void genlist_pop_back(struct genlist *pgenlist)
{
fc_assert_ret(pgenlist != nullptr);
if (pgenlist->tail_link != nullptr) {
genlist_link_destroy(pgenlist, pgenlist->tail_link);
}
......
****************************************************************************/
void genlist_insert(struct genlist *pgenlist, void *data, int pos)
{
fc_assert_ret(pgenlist != nullptr);
if (0 == pgenlist->nelements) {
/* List is empty, ignore pos. */
genlist_link_new(pgenlist, data, nullptr, nullptr);
......
void genlist_insert_after(struct genlist *pgenlist, void *data,
struct genlist_link *plink)
{
fc_assert_ret(pgenlist != nullptr);
genlist_link_new(pgenlist, data, plink,
plink != nullptr ? plink->next : pgenlist->head_link);
}
......
void genlist_insert_before(struct genlist *pgenlist, void *data,
struct genlist_link *plink)
{
fc_assert_ret(pgenlist != nullptr);
genlist_link_new(pgenlist, data,
plink != nullptr ? plink->prev : pgenlist->tail_link, plink);
}
......
****************************************************************************/
void genlist_prepend(struct genlist *pgenlist, void *data)
{
fc_assert_ret(pgenlist != nullptr);
genlist_link_new(pgenlist, data, nullptr, pgenlist->head_link);
}
......
****************************************************************************/
void genlist_append(struct genlist *pgenlist, void *data)
{
fc_assert_ret(pgenlist != nullptr);
genlist_link_new(pgenlist, data, pgenlist->tail_link, nullptr);
}
......
{
struct genlist_link *plink;
fc_assert_ret_val(pgenlist != nullptr, nullptr);
for (plink = pgenlist->head_link; plink; plink = plink->next) {
if (plink->dataptr == data) {
return plink;
......
struct genlist_link *genlist_search_if(const struct genlist *pgenlist,
genlist_cond_fn_t cond_data_func)
{
fc_assert_ret_val(pgenlist != nullptr, nullptr);
if (cond_data_func != nullptr) {
struct genlist_link *plink = pgenlist->head_link;
......
struct genlist_link *head, *tail;
int counter;
fc_assert_ret(pgenlist != nullptr);
head = pgenlist->head_link;
tail = pgenlist->tail_link;
for (counter = pgenlist->nelements / 2; 0 < counter; counter--) {
utility/genlist.h
genlist_free_fn_t free_data_func)
fc__warn_unused_result;
void genlist_clear(struct genlist *pgenlist);
void genlist_clear(struct genlist *pgenlist)
fc__attribute((nonnull (1)));
void genlist_unique(struct genlist *pgenlist);
void genlist_unique_full(struct genlist *pgenlist,
genlist_comp_fn_t comp_data_func);
void genlist_append(struct genlist *pgenlist, void *data);
void genlist_prepend(struct genlist *pgenlist, void *data);
void genlist_insert(struct genlist *pgenlist, void *data, int idx);
genlist_comp_fn_t comp_data_func)
fc__attribute((nonnull (1)));
void genlist_append(struct genlist *pgenlist, void *data)
fc__attribute((nonnull (1)));
void genlist_prepend(struct genlist *pgenlist, void *data)
fc__attribute((nonnull (1)));
void genlist_insert(struct genlist *pgenlist, void *data, int idx)
fc__attribute((nonnull (1)));
void genlist_insert_after(struct genlist *pgenlist, void *data,
struct genlist_link *plink);
struct genlist_link *plink)
fc__attribute((nonnull (1)));
void genlist_insert_before(struct genlist *pgenlist, void *data,
struct genlist_link *plink);
struct genlist_link *plink)
fc__attribute((nonnull (1)));
bool genlist_remove(struct genlist *pgenlist, const void *data);
bool genlist_remove(struct genlist *pgenlist, const void *data)
fc__attribute((nonnull (1)));
bool genlist_remove_if(struct genlist *pgenlist,
genlist_cond_fn_t cond_data_func);
int genlist_remove_all(struct genlist *pgenlist, const void *data);
genlist_cond_fn_t cond_data_func)
fc__attribute((nonnull (1)));
int genlist_remove_all(struct genlist *pgenlist, const void *data)
fc__attribute((nonnull (1)));
int genlist_remove_all_if(struct genlist *pgenlist,
genlist_cond_fn_t cond_data_func);
void genlist_erase(struct genlist *pgenlist, struct genlist_link *plink);
void genlist_pop_front(struct genlist *pgenlist);
void genlist_pop_back(struct genlist *pgenlist);
int genlist_size(const struct genlist *pgenlist);
genlist_cond_fn_t cond_data_func)
fc__attribute((nonnull (1)));
void genlist_erase(struct genlist *pgenlist, struct genlist_link *plink)
fc__attribute((nonnull (1)));
void genlist_pop_front(struct genlist *pgenlist)
fc__attribute((nonnull (1)));
void genlist_pop_back(struct genlist *pgenlist)
fc__attribute((nonnull (1)));
int genlist_size(const struct genlist *pgenlist)
fc__attribute((nonnull (1)));
void *genlist_get(const struct genlist *pgenlist, int idx);
void *genlist_front(const struct genlist *pgenlist);
void *genlist_back(const struct genlist *pgenlist);
struct genlist_link *genlist_link_get(const struct genlist *pgenlist, int idx);
struct genlist_link *genlist_link_get(const struct genlist *pgenlist, int idx)
fc__attribute((nonnull (1)));
inline static struct genlist_link *genlist_head(const struct genlist *pgenlist)
{
return (pgenlist != nullptr ? pgenlist->head_link : nullptr);
......
struct genlist_link *genlist_tail(const struct genlist *pgenlist);
struct genlist_link *genlist_search(const struct genlist *pgenlist,
const void *data);
const void *data)
fc__attribute((nonnull (1)));
struct genlist_link *genlist_search_if(const struct genlist *pgenlist,
genlist_cond_fn_t cond_data_func);
genlist_cond_fn_t cond_data_func)
fc__attribute((nonnull (1)));
void genlist_sort(struct genlist *pgenlist,
int (*compar) (const void *, const void *));
void genlist_shuffle(struct genlist *pgenlist);
void genlist_reverse(struct genlist *pgenlist);
void genlist_reverse(struct genlist *pgenlist)
fc__attribute((nonnull (1)));
void genlist_allocate_mutex(struct genlist *pgenlist);
void genlist_release_mutex(struct genlist *pgenlist);
    (1-1/1)