Skip to content

Possibly stale examples in ps_list #9

@bushidocodes

Description

@bushidocodes

I've been playing with ps_list a bit in a REPL. Please disregard my refactors. I tend to prefer verbosity.

I notice the following problems with the examples though

ps_list_head is undefined as a function

  for (i = ps_list_head_first(&h, struct foo, l) ;
       i != ps_list_head(&h, struct foo, l) ;
       i = ps_list_next(i, l)) { ... }

I did the following instead

for (struct foo *i = ps_list_head_first(&list_head, struct foo, list);
     i <= ps_list_head_last(&list_head, struct foo, list);
     i = ps_list_next(i, list)) { ... }

ps_list_iter_init and ps_list_iter_term are undefined

for (ps_list_iter_init(&h, i, l) ; !ps_list_iter_term(&h, i, l) ; i = ps_list_next(i, l)) { ... }

I didn't really see the use case for this syntax when the traditional imperative and foreach are both available. Was this perhaps an old API you got rid of?

ps_free is undefined. I'm not super sure what needs to be cleaned up here.

 ps_list_foreach_del(&h, i, tmp, l) {
          ps_list_rem(i, l);
          ps_free(i);
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions