Project

General

Profile

Actions

Bug #14591

open

list_create(9f): provide example of safely deleting specific entries in the loop

Added by Yuri Pankov 5 months ago. Updated 5 months ago.

Status:
New
Priority:
Low
Assignee:
-
Category:
manpage - manual pages
Start date:
Due date:
% Done:

0%

Estimated time:
Difficulty:
Bite-size
Tags:
Gerrit CR:

Description

This puzzled me a bit, so I have taken the following logic from STAILQ_FOREACH_SAFE to safely remove specific entries while walking the list, which could be documented in the man page:

list_t list;
foo_t foo, tfoo;
...
for (foo = list_head(&list); foo != NULL && (tfoo = list_next(&list, foo), 1); foo = tfoo) {
    ...
    if (condition)
        list_remove(&list, foo);
}

It is not ideal, of course, so if there is any better solution, that could be added instead.

Actions

Also available in: Atom PDF