[pacman-dev] alpm_list_t

Aaron Griffin aaronmgriffin at gmail.com
Wed Nov 21 12:56:49 EST 2007

On Nov 21, 2007 9:28 AM, Justin Lampley <jrlampley at gmail.com> wrote:
> One possible solution is to create a alpm_list_t struct and a
> alpm_list_node_t struct like Nagy suggested in another thread.  The
> alpm_list_t struct would contain:
> struct alpm_list_t {
> alpm_list_node_t *first;
> alpm_list_node_t *last;
> int size; (possibly)
> }

Yeah. Dan suggested the same thing at one point. It's fine by me if
someone wants to do this.

Here's another suggestion though, to make all our cleanup headaches...
well, less painful.

struct alpm_list_t {
    alpm_list_node_t *first;
    alpm_list_node_t *last;
    alpm_list_fn_free *freefn;
    size_t size;

then we rework alpm_list_free to do:

if(list->freefn) {

Here's what we gain:
* The ability to say "free all lists" in all alpm calls, while simply
setting the freefn to NULL when returning package lists.
* Less book keeping
* No need for list freeing macros and knowing when and when not to
call free_inner
* No need for free_inner

Potential con:
* Requires homogeneous lists that is not enforced in anyway. We do
this now, but it could introduce more potential error based on the
fact that we're making this op easier.


More information about the pacman-dev mailing list