libalpm
Arch Linux Package Manager Library
|
Functions to manipulate alpm_list_t lists. More...
Functions | |
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_t * | alpm_list_add (alpm_list_t *list, void *data) |
Add a new item to the end of the list. | |
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. | |
alpm_list_t * | alpm_list_join (alpm_list_t *first, alpm_list_t *second) |
Join two lists. | |
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. | |
alpm_list_t * | alpm_list_msort (alpm_list_t *list, size_t n, alpm_list_fn_cmp fn) |
Sort a list of size `n` using mergesort algorithm. | |
alpm_list_t * | alpm_list_remove_item (alpm_list_t *haystack, alpm_list_t *item) |
Remove an item from the list. | |
alpm_list_t * | alpm_list_remove (alpm_list_t *haystack, const void *needle, alpm_list_fn_cmp fn, void **data) |
Remove an item from the list. | |
alpm_list_t * | alpm_list_remove_str (alpm_list_t *haystack, const char *needle, char **data) |
Remove a string from a list. | |
alpm_list_t * | alpm_list_remove_dupes (const alpm_list_t *list) |
Create a new list without any duplicates. | |
alpm_list_t * | alpm_list_strdup (const alpm_list_t *list) |
Copy a string list, including data. | |
alpm_list_t * | alpm_list_copy (const alpm_list_t *list) |
Copy a list, without copying data. | |
alpm_list_t * | alpm_list_copy_data (const alpm_list_t *list, size_t size) |
Copy a list and copy the data. | |
alpm_list_t * | alpm_list_reverse (alpm_list_t *list) |
Create a new list in reverse order. | |
alpm_list_t * | alpm_list_nth (const alpm_list_t *list, size_t n) |
Return nth element from list (starting from 0). | |
alpm_list_t * | alpm_list_next (const alpm_list_t *node) |
Get the next element of a list. | |
alpm_list_t * | alpm_list_previous (const alpm_list_t *list) |
Get the previous element of a list. | |
alpm_list_t * | alpm_list_last (const alpm_list_t *list) |
Get the last item in the list. | |
size_t | 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. | |
void | alpm_list_diff_sorted (const alpm_list_t *left, const alpm_list_t *right, alpm_list_fn_cmp fn, alpm_list_t **onlyleft, alpm_list_t **onlyright) |
Find the differences between list `left` and list `right`. | |
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`. | |
void * | alpm_list_to_array (const alpm_list_t *list, size_t n, size_t size) |
Copy a list and data into a standard C array of fixed length. |
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.
alpm_list_t* alpm_list_add | ( | alpm_list_t * | list, |
void * | data | ||
) |
Add a new item to the end of the list.
list | the list to add to |
data | the new item to be added to the list |
Definition at line 88 of file alpm_list.c.
References alpm_list_last(), __alpm_list_t::data, __alpm_list_t::next, and __alpm_list_t::prev.
Referenced by _alpm_db_find_fileconflicts(), _alpm_db_register_sync(), _alpm_db_search(), _alpm_pkg_dup(), _alpm_recursedeps(), _alpm_resolvedeps(), _alpm_sortbydeps(), _alpm_sync_prepare(), _alpm_unpack_single(), alpm_add_pkg(), alpm_checkdeps(), alpm_db_add_server(), alpm_find_group_pkgs(), alpm_list_add_sorted(), alpm_list_copy(), alpm_list_copy_data(), alpm_list_diff_sorted(), alpm_list_remove_dupes(), alpm_list_reverse(), alpm_list_strdup(), alpm_option_add_cachedir(), alpm_option_add_ignoregroup(), alpm_option_add_ignorepkg(), alpm_option_add_noextract(), alpm_option_add_noupgrade(), alpm_remove_pkg(), alpm_sync_sysupgrade(), cb_log(), cb_question(), display_targets(), main(), pacman_deptest(), pacman_upgrade(), select_display(), strreplace(), and strsplit().
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.
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 |
Definition at line 123 of file alpm_list.c.
References alpm_list_add(), __alpm_list_t::data, __alpm_list_t::next, and __alpm_list_t::prev.
alpm_list_t* alpm_list_copy | ( | const alpm_list_t * | list | ) |
Copy a list, without copying data.
list | the list to copy |
Definition at line 453 of file alpm_list.c.
References alpm_list_add(), __alpm_list_t::data, and __alpm_list_t::next.
Referenced by _alpm_db_search(), _alpm_resolvedeps(), and alpm_list_diff().
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.
list | the list to copy |
size | the size of each data element |
Definition at line 474 of file alpm_list.c.
References alpm_list_add(), __alpm_list_t::data, and __alpm_list_t::next.
size_t alpm_list_count | ( | const alpm_list_t * | list | ) |
Get the number of items in a list.
list | the list |
Definition at line 595 of file alpm_list.c.
References __alpm_list_t::next.
Referenced by _alpm_check_diskspace(), _alpm_db_find_fileconflicts(), _alpm_remove_packages(), _alpm_upgrade_packages(), alpm_list_diff(), alpm_pkg_compute_requiredby(), cb_question(), display_targets(), strreplace(), and table_display().
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`.
lhs | the first list |
rhs | the second list |
fn | the comparison function |
Definition at line 732 of file alpm_list.c.
References alpm_list_copy(), alpm_list_count(), alpm_list_diff_sorted(), alpm_list_free(), and alpm_list_msort().
Referenced by _alpm_outerconflicts(), _alpm_sync_prepare(), display_new_optdepends(), and pacman_sync().
void alpm_list_diff_sorted | ( | const alpm_list_t * | left, |
const alpm_list_t * | right, | ||
alpm_list_fn_cmp | fn, | ||
alpm_list_t ** | onlyleft, | ||
alpm_list_t ** | onlyright | ||
) |
Find the differences between list `left` and list `right`.
The two lists must be sorted. Items only in list `left` are added to the `onlyleft` list. Items only in list `right` are added to the `onlyright` list.
left | the first list |
right | the second list |
fn | the comparison function |
onlyleft | pointer to the first result list |
onlyright | pointer to the second result list |
Definition at line 679 of file alpm_list.c.
References alpm_list_add(), __alpm_list_t::data, and __alpm_list_t::next.
Referenced by alpm_list_diff().
void* alpm_list_find | ( | const alpm_list_t * | haystack, |
const void * | needle, | ||
alpm_list_fn_cmp | fn | ||
) |
Find an item in a list.
needle | the item to search |
haystack | the list |
fn | the comparison function for searching (!= NULL) |
Definition at line 615 of file alpm_list.c.
References __alpm_list_t::data, and __alpm_list_t::next.
Referenced by _alpm_pkg_should_ignore(), alpm_list_find_ptr(), alpm_list_find_str(), display_targets(), and pacman_remove().
void* alpm_list_find_ptr | ( | const alpm_list_t * | haystack, |
const void * | needle | ||
) |
Find an item in a list.
Search for the item whose data matches that of the `needle`.
needle | the data to search for (== comparison) |
haystack | the list |
Definition at line 644 of file alpm_list.c.
References alpm_list_find().
Referenced by alpm_list_remove_dupes().
char* alpm_list_find_str | ( | const alpm_list_t * | haystack, |
const char * | needle | ||
) |
Find a string in a list.
needle | the string to search for |
haystack | the list |
Definition at line 658 of file alpm_list.c.
References alpm_list_find().
Referenced by _alpm_unpack(), and main().
void alpm_list_free | ( | alpm_list_t * | list | ) |
Free a list, but not the contained data.
list | the list to free |
Definition at line 48 of file alpm_list.c.
References __alpm_list_t::next.
Referenced by _alpm_db_find_fileconflicts(), _alpm_db_search(), _alpm_gpgme_checksig(), _alpm_graph_free(), _alpm_group_free(), _alpm_outerconflicts(), _alpm_pkg_free(), _alpm_pkg_free_trans(), _alpm_remove_prepare(), _alpm_resolvedeps(), _alpm_shortest_delta_path(), _alpm_sortbydeps(), _alpm_sync_commit(), _alpm_sync_prepare(), _alpm_trans_free(), _alpm_unpack_single(), alpm_checkdeps(), alpm_find_group_pkgs(), alpm_list_diff(), cb_question(), config_free(), display_new_optdepends(), main(), pacman_deptest(), pacman_sync(), and strreplace().
void alpm_list_free_inner | ( | alpm_list_t * | list, |
alpm_list_fn_free | fn | ||
) |
Free the internal data of a list structure.
list | the list to free |
fn | a free function for the internal data |
Definition at line 65 of file alpm_list.c.
References __alpm_list_t::data, and __alpm_list_t::next.
Referenced by _alpm_db_free_pkgcache(), _alpm_pkg_free(), _alpm_remove_prepare(), _alpm_shortest_delta_path(), _alpm_sortbydeps(), _alpm_sync_commit(), _alpm_sync_prepare(), and _alpm_trans_free().
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.
first | the first list |
second | the second list |
Definition at line 176 of file alpm_list.c.
References __alpm_list_t::next, and __alpm_list_t::prev.
Referenced by alpm_sync_sysupgrade().
alpm_list_t* alpm_list_last | ( | const alpm_list_t * | list | ) |
Get the last item in the list.
list | the list |
Definition at line 577 of file alpm_list.c.
References __alpm_list_t::prev.
Referenced by _alpm_resolvedeps(), alpm_list_add(), and alpm_list_reverse().
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.
left | the first list |
right | the second list |
fn | comparison function for determining merge order |
Definition at line 207 of file alpm_list.c.
References __alpm_list_t::data, __alpm_list_t::next, and __alpm_list_t::prev.
Referenced by alpm_list_msort().
alpm_list_t* alpm_list_msort | ( | alpm_list_t * | list, |
size_t | n, | ||
alpm_list_fn_cmp | fn | ||
) |
Sort a list of size `n` using mergesort algorithm.
list | the list to sort |
n | the size of the list |
fn | the comparison function for determining order |
Definition at line 277 of file alpm_list.c.
References alpm_list_mmerge(), alpm_list_msort(), and __alpm_list_t::next.
Referenced by alpm_list_diff(), alpm_list_msort(), alpm_pkg_compute_requiredby(), and display_targets().
alpm_list_t* alpm_list_next | ( | const alpm_list_t * | node | ) | [inline] |
Get the next element of a list.
node | the list node |
Definition at line 545 of file alpm_list.c.
References __alpm_list_t::next.
Referenced by check_syncdbs(), display_targets(), dump_pkg_backups(), list_display(), list_display_linebreak(), main(), pacman_database(), pacman_deptest(), pacman_query(), pacman_remove(), pacman_upgrade(), print_packages(), strreplace(), sync_prepare_execute(), and table_display().
alpm_list_t* alpm_list_nth | ( | const alpm_list_t * | list, |
size_t | n | ||
) |
Return nth element from list (starting from 0).
list | the list |
n | the index of the item to find (n < alpm_list_count(list) IS needed) |
Definition at line 529 of file alpm_list.c.
References __alpm_list_t::next.
alpm_list_t* alpm_list_previous | ( | const alpm_list_t * | list | ) | [inline] |
Get the previous element of a list.
list | the list head |
Definition at line 561 of file alpm_list.c.
References __alpm_list_t::next, and __alpm_list_t::prev.
alpm_list_t* alpm_list_remove | ( | alpm_list_t * | haystack, |
const void * | needle, | ||
alpm_list_fn_cmp | fn, | ||
void ** | data | ||
) |
Remove an item from the list.
haystack | the list to remove the item from |
needle | the data member of the item we're removing |
fn | the comparison function for searching |
data | output parameter containing data of the removed item |
Definition at line 356 of file alpm_list.c.
References alpm_list_remove_item(), __alpm_list_t::data, and __alpm_list_t::next.
Referenced by _alpm_sync_prepare(), alpm_db_unregister(), and alpm_list_remove_str().
alpm_list_t* alpm_list_remove_dupes | ( | const alpm_list_t * | list | ) |
Create a new list without any duplicates.
This does NOT copy data members.
list | the list to copy |
Definition at line 415 of file alpm_list.c.
References alpm_list_add(), alpm_list_find_ptr(), __alpm_list_t::data, and __alpm_list_t::next.
alpm_list_t* alpm_list_remove_item | ( | alpm_list_t * | haystack, |
alpm_list_t * | item | ||
) |
Remove an item from the list.
item is not freed; this is the responsibility of the caller.
haystack | the list to remove the item from |
item | the item to remove from the list |
Definition at line 308 of file alpm_list.c.
References __alpm_list_t::next, and __alpm_list_t::prev.
Referenced by _alpm_pkghash_remove(), _alpm_resolvedeps(), and alpm_list_remove().
alpm_list_t* alpm_list_remove_str | ( | alpm_list_t * | haystack, |
const char * | needle, | ||
char ** | data | ||
) |
Remove a string from a list.
haystack | the list to remove the item from |
needle | the data member of the item we're removing |
data | output parameter containing data of the removed item |
Definition at line 399 of file alpm_list.c.
References alpm_list_remove().
Referenced by alpm_db_remove_server(), alpm_option_remove_cachedir(), alpm_option_remove_ignoregroup(), alpm_option_remove_ignorepkg(), alpm_option_remove_noextract(), alpm_option_remove_noupgrade(), and main().
alpm_list_t* alpm_list_reverse | ( | alpm_list_t * | list | ) |
Create a new list in reverse order.
list | the list to copy |
Definition at line 497 of file alpm_list.c.
References alpm_list_add(), alpm_list_last(), __alpm_list_t::data, and __alpm_list_t::prev.
Referenced by _alpm_sortbydeps().
alpm_list_t* alpm_list_strdup | ( | const alpm_list_t * | list | ) |
Copy a string list, including data.
list | the list to copy |
Definition at line 435 of file alpm_list.c.
References alpm_list_add(), __alpm_list_t::data, and __alpm_list_t::next.
Referenced by _alpm_pkg_dup(), alpm_option_set_ignoregroups(), alpm_option_set_ignorepkgs(), alpm_option_set_noextracts(), alpm_option_set_noupgrades(), and pacman_sync().
void* alpm_list_to_array | ( | const alpm_list_t * | list, |
size_t | n, | ||
size_t | size | ||
) |
Copy a list and data into a standard C array of fixed length.
Note that the data elements are shallow copied so any contained pointers will point to the original data.
list | the list to copy |
n | the size of the list |
size | the size of each data element |
Definition at line 761 of file alpm_list.c.
References __alpm_list_t::next.
Referenced by _alpm_db_find_fileconflicts().