List Functions

Functions to manipulate alpm_list_t lists. More...

Functions

alpm_list_talpm_list_new ()
 Allocate a new alpm_list_t.
void alpm_list_free (alpm_list_t *list)
 Free a list, but not the contained data.
void alpm_list_free_inner (alpm_list_t *list, alpm_list_fn_free fn)
 Free the internal data of a list structure.
alpm_list_talpm_list_add (alpm_list_t *list, void *data)
 Add a new item to the end of the list.
alpm_list_talpm_list_add_sorted (alpm_list_t *list, void *data, alpm_list_fn_cmp fn)
 Add items to a list in sorted order.
alpm_list_talpm_list_join (alpm_list_t *first, alpm_list_t *second)
 Join two lists. The two lists must be independent. Do not free the original lists after calling this function, as this is not a copy operation. The list pointers passed in should be considered invalid after calling this function.
alpm_list_talpm_list_mmerge (alpm_list_t *left, alpm_list_t *right, alpm_list_fn_cmp fn)
 Merge the two sorted sublists into one sorted list.
alpm_list_talpm_list_msort (alpm_list_t *list, int n, alpm_list_fn_cmp fn)
 Sort a list of size `n` using mergesort algorithm.
alpm_list_talpm_list_remove (alpm_list_t *haystack, const void *needle, alpm_list_fn_cmp fn, void **data)
 Remove an item from the list.
alpm_list_talpm_list_remove_dupes (const alpm_list_t *list)
 Create a new list without any duplicates.
alpm_list_talpm_list_strdup (const alpm_list_t *list)
 Copy a string list, including data.
alpm_list_talpm_list_copy (const alpm_list_t *list)
 Copy a list, without copying data.
alpm_list_talpm_list_copy_data (const alpm_list_t *list, size_t size)
 Copy a list and copy the data. Note that the data elements to be copied should not contain pointers and should also be of constant size.
alpm_list_talpm_list_reverse (alpm_list_t *list)
 Create a new list in reverse order.
alpm_list_talpm_list_first (const alpm_list_t *list)
 Get the first element of a list.
alpm_list_talpm_list_nth (const alpm_list_t *list, int n)
 Return nth element from list (starting from 0).
alpm_list_talpm_list_next (const alpm_list_t *node)
 Get the next element of a list.
alpm_list_talpm_list_last (const alpm_list_t *list)
 Get the last item in the list.
void * alpm_list_getdata (const alpm_list_t *node)
 Get the data member of a list node.
int alpm_list_count (const alpm_list_t *list)
 Get the number of items in a list.
void * alpm_list_find (const alpm_list_t *haystack, const void *needle, alpm_list_fn_cmp fn)
 Find an item in a list.
void * alpm_list_find_ptr (const alpm_list_t *haystack, const void *needle)
 Find an item in a list.
char * alpm_list_find_str (const alpm_list_t *haystack, const char *needle)
 Find a string in a list.
alpm_list_talpm_list_diff (const alpm_list_t *lhs, const alpm_list_t *rhs, alpm_list_fn_cmp fn)
 Find the items in list `lhs` that are not present in list `rhs`.

Detailed Description

Functions to manipulate alpm_list_t lists.

These functions are designed to create, destroy, and modify lists of type alpm_list_t. This is an internal list type used by libalpm that is publicly exposed for use by frontends if desired.


Function Documentation

alpm_list_t* alpm_list_add ( alpm_list_t list,
void *  data 
)

Add a new item to the end of the list.

Parameters:
list the list to add to
data the new item to be added to the list
Returns:
the resultant list

Definition at line 106 of file alpm_list.c.

References alpm_list_last(), alpm_list_new(), __alpm_list_t::data, __alpm_list_t::next, and __alpm_list_t::prev.

Referenced by _alpm_add_loadtarget(), _alpm_db_find_fileconflicts(), _alpm_db_load_pkgcache(), _alpm_db_read(), _alpm_db_register_sync(), _alpm_db_search(), _alpm_db_whatprovides(), _alpm_downloadfiles_forreal(), _alpm_filecache_setup(), _alpm_pkg_dup(), _alpm_pkg_load(), _alpm_recursedeps(), _alpm_remove_loadtarget(), _alpm_remove_prepare(), _alpm_resolvedeps(), _alpm_sortbydeps(), _alpm_sync_addtarget(), _alpm_sync_commit(), _alpm_sync_prepare(), _alpm_sync_sysupgrade(), _alpm_trans_addtarget(), alpm_checkdeps(), alpm_db_setserver(), alpm_db_update(), alpm_fetch_pkgurl(), alpm_list_add_sorted(), alpm_list_copy(), alpm_list_copy_data(), alpm_list_diff(), alpm_list_remove_dupes(), alpm_list_reverse(), alpm_list_strdup(), alpm_option_add_cachedir(), alpm_option_add_holdpkg(), alpm_option_add_ignoregrp(), alpm_option_add_ignorepkg(), alpm_option_add_noextract(), alpm_option_add_noupgrade(), alpm_pkg_compute_requiredby(), cb_log(), display_targets(), dump_pkg_full(), pacman_remove(), and strsplit().

Here is the call graph for this function:

Here is the caller graph for this function:

alpm_list_t* alpm_list_add_sorted ( alpm_list_t list,
void *  data,
alpm_list_fn_cmp  fn 
)

Add items to a list in sorted order.

Parameters:
list the list to add to
data the new item to be added to the list
fn the comparison function to use to determine order
Returns:
the resultant list

Definition at line 145 of file alpm_list.c.

References alpm_list_add(), alpm_list_new(), and __alpm_list_t::prev.

Referenced by _alpm_db_add_pkgincache(), and _alpm_db_load_grpcache().

Here is the call graph for this function:

Here is the caller graph for this function:

alpm_list_t* alpm_list_copy ( const alpm_list_t list  ) 

Copy a list, without copying data.

Parameters:
list the list to copy
Returns:
a copy of the original list

Definition at line 420 of file alpm_list.c.

References alpm_list_add(), __alpm_list_t::data, and __alpm_list_t::next.

Referenced by alpm_checkdeps().

Here is the call graph for this function:

Here is the caller graph for this function:

alpm_list_t* alpm_list_copy_data ( const alpm_list_t list,
size_t  size 
)

Copy a list and copy the data. Note that the data elements to be copied should not contain pointers and should also be of constant size.

Parameters:
list the list to copy
size the size of each data element
Returns:
a copy of the original list, data copied as well

Definition at line 441 of file alpm_list.c.

References alpm_list_add(), __alpm_list_t::data, and __alpm_list_t::next.

Referenced by _alpm_pkg_dup().

Here is the call graph for this function:

Here is the caller graph for this function:

int alpm_list_count ( const alpm_list_t list  ) 

Get the number of items in a list.

Parameters:
list the list
Returns:
the number of list items

Definition at line 563 of file alpm_list.c.

References __alpm_list_t::next.

Referenced by _alpm_add_commit(), _alpm_db_find_fileconflicts(), _alpm_downloadfiles_forreal(), _alpm_pkg_load(), _alpm_remove_commit(), pacman_query(), and pacman_sync().

Here is the caller graph for this function:

alpm_list_t* alpm_list_diff ( const alpm_list_t lhs,
const alpm_list_t rhs,
alpm_list_fn_cmp  fn 
)

Find the items in list `lhs` that are not present in list `rhs`.

Entries are not duplicated. Operation is O(m*n). The first list is stepped through one node at a time, and for each node in the first list, each node in the second list is compared to it.

Parameters:
lhs the first list
rhs the second list
fn the comparison function
Returns:
a list containing all items in `lhs` not present in `rhs`

Definition at line 643 of file alpm_list.c.

References alpm_list_add(), __alpm_list_t::data, and __alpm_list_t::next.

Referenced by _alpm_outerconflicts().

Here is the call graph for this function:

Here is the caller graph for this function:

void* alpm_list_find ( const alpm_list_t haystack,
const void *  needle,
alpm_list_fn_cmp  fn 
)

Find an item in a list.

Parameters:
needle the item to search
haystack the list
fn the comparison function for searching (!= NULL)
Returns:
`needle` if found, NULL otherwise

Definition at line 583 of file alpm_list.c.

References __alpm_list_t::data, and __alpm_list_t::next.

Referenced by _alpm_db_whatprovides(), _alpm_sync_prepare(), alpm_checkdeps(), alpm_list_find_ptr(), and alpm_list_find_str().

Here is the caller graph for this function:

void* alpm_list_find_ptr ( const alpm_list_t haystack,
const void *  needle 
)

Find an item in a list.

Search for the item whos data matches that of the `needle`.

Parameters:
needle the data to search for (== comparison)
haystack the list
Returns:
`needle` if found, NULL otherwise

Definition at line 612 of file alpm_list.c.

References alpm_list_find().

Referenced by alpm_db_update(), and alpm_list_remove_dupes().

Here is the call graph for this function:

Here is the caller graph for this function:

char* alpm_list_find_str ( const alpm_list_t haystack,
const char *  needle 
)

Find a string in a list.

Parameters:
needle the string to search for
haystack the list
Returns:
`needle` if found, NULL otherwise

Definition at line 625 of file alpm_list.c.

References alpm_list_find().

Referenced by _alpm_db_find_fileconflicts(), _alpm_db_load_grpcache(), _alpm_downloadfiles_forreal(), _alpm_pkg_should_ignore(), _alpm_remove_loadtarget(), _alpm_sync_prepare(), _alpm_trans_addtarget(), and display_targets().

Here is the call graph for this function:

Here is the caller graph for this function:

alpm_list_t* alpm_list_first ( const alpm_list_t list  )  [inline]

Get the first element of a list.

Parameters:
list the list
Returns:
the first element in the list

Definition at line 491 of file alpm_list.c.

void alpm_list_free ( alpm_list_t list  ) 

Free a list, but not the contained data.

Parameters:
list the list to free

Definition at line 66 of file alpm_list.c.

References __alpm_list_t::next.

Referenced by _alpm_add_prepare(), _alpm_db_free(), _alpm_db_free_grpcache(), _alpm_db_free_pkgcache(), _alpm_downloadfiles_forreal(), _alpm_outerconflicts(), _alpm_pkg_free(), _alpm_remove_commit(), _alpm_remove_prepare(), _alpm_resolvedeps(), _alpm_sortbydeps(), _alpm_sync_commit(), _alpm_sync_free(), _alpm_sync_prepare(), _alpm_trans_free(), alpm_checkdeps(), alpm_fetch_pkgurl(), alpm_pkg_download_size(), pacman_add(), and pacman_deptest().

Here is the caller graph for this function:

void alpm_list_free_inner ( alpm_list_t list,
alpm_list_fn_free  fn 
)

Free the internal data of a list structure.

Parameters:
list the list to free
fn a free function for the internal data

Definition at line 83 of file alpm_list.c.

References __alpm_list_t::data, and __alpm_list_t::next.

Referenced by _alpm_add_prepare(), _alpm_pkg_free(), _alpm_remove_prepare(), _alpm_resolvedeps(), _alpm_sortbydeps(), _alpm_sync_prepare(), and _alpm_trans_free().

Here is the caller graph for this function:

void* alpm_list_getdata ( const alpm_list_t node  ) 

Get the data member of a list node.

Parameters:
node the list node
Returns:
the contained data, or NULL if none

Definition at line 548 of file alpm_list.c.

References __alpm_list_t::data.

Referenced by _alpm_delta_path_size(), _alpm_delta_path_size_uncached(), _alpm_filecache_find(), _alpm_filecache_setup(), _alpm_pkg_should_ignore(), _alpm_sync_commit(), display_targets(), dump_pkg_backups(), dump_pkg_files(), dump_pkg_full(), list_display(), main(), pacman_add(), pacman_deptest(), pacman_query(), and pacman_remove().

Here is the caller graph for this function:

alpm_list_t* alpm_list_join ( alpm_list_t first,
alpm_list_t second 
)

Join two lists. The two lists must be independent. Do not free the original lists after calling this function, as this is not a copy operation. The list pointers passed in should be considered invalid after calling this function.

Parameters:
first the first list
second the second list
Returns:
the resultant joined list

Definition at line 196 of file alpm_list.c.

References __alpm_list_t::next, and __alpm_list_t::prev.

Referenced by _alpm_add_prepare(), _alpm_checkconflicts(), and alpm_checkdeps().

Here is the caller graph for this function:

alpm_list_t* alpm_list_last ( const alpm_list_t list  ) 

Get the last item in the list.

Parameters:
list the list
Returns:
the last element in the list

Definition at line 532 of file alpm_list.c.

References __alpm_list_t::prev.

Referenced by _alpm_sync_commit(), alpm_list_add(), and alpm_list_reverse().

Here is the caller graph for this function:

alpm_list_t* alpm_list_mmerge ( alpm_list_t left,
alpm_list_t right,
alpm_list_fn_cmp  fn 
)

Merge the two sorted sublists into one sorted list.

Parameters:
left the first list
right the second list
fn comparison function for determining merge order
Returns:
the resultant list

Definition at line 227 of file alpm_list.c.

References __alpm_list_t::data, __alpm_list_t::next, and __alpm_list_t::prev.

Referenced by alpm_list_msort().

Here is the caller graph for this function:

alpm_list_t* alpm_list_msort ( alpm_list_t list,
int  n,
alpm_list_fn_cmp  fn 
)

Sort a list of size `n` using mergesort algorithm.

Parameters:
list the list to sort
n the size of the list
fn the comparison function for determining order
Returns:
the resultant list

Definition at line 291 of file alpm_list.c.

References alpm_list_mmerge(), alpm_list_msort(), alpm_list_nth(), and __alpm_list_t::next.

Referenced by _alpm_db_load_pkgcache(), _alpm_pkg_load(), and alpm_list_msort().

Here is the call graph for this function:

Here is the caller graph for this function: