libalpm_list(3)

๐Ÿ“ฆ
version 7.1.0.r9.g54d9411 ยท 4 versions
, in arch rolling, fedora 44

โœจ NAME โœจ

libalpm_list โ€” libalpm_list(3), no cap. ๐Ÿ’…


๐ŸŒธ SYNOPSIS ๐ŸŒธ

Okay bestie, here's the whole cast of characters. No cap, every single signature is here. ๐Ÿ’–

๐ŸŽ€ Data Structures ๐ŸŽ€

  • struct alpm_list_t โ€” a doubly linked list. She's connected both ways, iykyk. ๐Ÿ”—

๐Ÿฆ‹ Macros ๐Ÿฆ‹

  • #define FREELIST(p) โ€” frees a list and its contents. Cleanup queen. ๐Ÿงน

๐Ÿ’– Typedefs ๐Ÿ’–

  • typedef void(* alpm_list_fn_free) (void *item) โ€” item deallocation callback. Say bye to an item. ๐Ÿ‘‹
  • typedef int(* alpm_list_fn_cmp) (const void *, const void *) โ€” item comparison callback. Compare girlies. โš–๏ธ

๐Ÿ‘‘ Functions ๐Ÿ‘‘

Now the main event, bestie. Every function, every signature, exactly as she is. โœจ

  • void alpm_list_free (alpm_list_t *list) โ€” free a list, but not the contained data. The list dips, the data stays. ๐Ÿ’…
  • void alpm_list_free_inner (alpm_list_t *list, alpm_list_fn_free fn) โ€” free the internal data of a list structure but not the list itself. Contents gone, skeleton remains. ๐Ÿฆด
  • alpm_list_t * alpm_list_add (alpm_list_t *list, void *data) โ€” add a new item to the end of the list. Append era. ๐Ÿ“
  • alpm_list_t * alpm_list_append (alpm_list_t **list, void *data) โ€” add a new item to the end of the list. Same energy, different pointer-to-pointer signature. ๐Ÿ’ซ
  • alpm_list_t * alpm_list_append_strdup (alpm_list_t **list, const char *data) โ€” duplicate and append a string to a list. Copy queen behavior. ๐Ÿ‘‘
  • 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. Order is the moment. ๐Ÿ“
  • alpm_list_t * alpm_list_join (alpm_list_t *first, alpm_list_t *second) โ€” join two lists. Union vibes. ๐Ÿค
  • 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. Merge sort core, bestie. ๐Ÿงฌ
  • 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. Algorithmically iconic. ๐Ÿง 
  • alpm_list_t * alpm_list_remove_item (alpm_list_t *haystack, alpm_list_t *item) โ€” remove an item from the list. Bye bye. ๐Ÿ—‘๏ธ
  • 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. Needle, fn, and data out-param, iykyk. ๐ŸŽฏ
  • alpm_list_t * alpm_list_remove_str (alpm_list_t *haystack, const char *needle, char **data) โ€” remove a string from a list. String removal slay. โœ‚๏ธ
  • alpm_list_t * alpm_list_remove_dupes (const alpm_list_t *list) โ€” create a new list without any duplicates. Dedupe queen. ๐Ÿงผ
  • alpm_list_t * alpm_list_strdup (const alpm_list_t *list) โ€” copy a string list, including data. Copy the whole vibe, data included. ๐Ÿ’–
  • alpm_list_t * alpm_list_copy (const alpm_list_t *list) โ€” copy a list, without copying data. She's not duplicating the contents. ๐Ÿชž
  • alpm_list_t * alpm_list_copy_data (const alpm_list_t *list, size_t size) โ€” copy a list and copy the data. She's duplicating everything. ๐Ÿงš
  • alpm_list_t * alpm_list_reverse (alpm_list_t *list) โ€” create a new list in reverse order. Backwards but make it fashion. ๐Ÿ”„
  • alpm_list_t * alpm_list_nth (const alpm_list_t *list, size_t n) โ€” return nth element from list (starting from 0). Zero-indexed, as she should. 0๏ธโƒฃ
  • alpm_list_t * alpm_list_next (const alpm_list_t *list) โ€” get the next element of a list. Next up. โžก๏ธ
  • alpm_list_t * alpm_list_previous (const alpm_list_t *list) โ€” get the previous element of a list. Rewind. โฌ…๏ธ
  • alpm_list_t * alpm_list_last (const alpm_list_t *list) โ€” get the last item in the list. Final boss. ๐Ÿ
  • size_t alpm_list_count (const alpm_list_t *list) โ€” get the number of items in a list. Count her. ๐Ÿ”ข
  • void * alpm_list_find (const alpm_list_t *haystack, const void *needle, alpm_list_fn_cmp fn) โ€” find an item in a list. Search era. ๐Ÿ”
  • void * alpm_list_find_ptr (const alpm_list_t *haystack, const void *needle) โ€” find an item in a list. Pointer edition. ๐Ÿ“
  • char * alpm_list_find_str (const alpm_list_t *haystack, const char *needle) โ€” find a string in a list. String search, bestie. ๐Ÿ”Ž
  • int alpm_list_cmp_unsorted (const alpm_list_t *left, const alpm_list_t *right, alpm_list_fn_cmp fn) โ€” check if two lists contain the same data, ignoring order. Order is not the moment. ๐ŸŒ€
  • 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. Diff era, but sorted. ๐Ÿงฎ
  • 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. Left has, right doesn't. ๐Ÿ•ต๏ธ
  • 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. C array glow-up. ๐Ÿ“ฆ

๐Ÿ’ซ Detailed Description ๐Ÿ’ซ

Okay so, these are the functions to manipulate alpm_list_t lists. Literally the whole point. ๐Ÿ’…

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. So she's internal but also out here, iykyk. โœจ

It is exposed so front ends can use it to prevent the need to reimplement lists of their own; however, it is not required that the front end uses it. No pressure, bestie. ๐Ÿซถ


๐Ÿฆ‹ Data Structure Documentation ๐Ÿฆ‹

๐ŸŒธ struct alpm_list_t ๐ŸŒธ

A doubly linked list. She's linked both ways, no cap. ๐Ÿ”—

Data Fields:

  • void * data โ€” data held by the list node. Her contents. ๐Ÿ’–
  • struct _alpm_list_t * next โ€” pointer to the next node. Forward. โžก๏ธ
  • struct _alpm_list_t * prev โ€” pointer to the previous node. Backward. โฌ…๏ธ

๐Ÿ’… Macro Definition Documentation ๐Ÿ’…

๐ŸŽ€ #define FREELIST( p) ๐ŸŽ€

Value:

do { alpm_list_free_inner(p, free); alpm_list_free(p); p = NULL; } while(0)

Frees a list and its contents. Cleanup, cleanup, everybody everywhere. ๐Ÿงนโœจ


๐Ÿงš Typedef Documentation ๐Ÿงš

โš–๏ธ typedef int(* alpm_list_fn_cmp) (const void *, const void *) โš–๏ธ

Item comparison callback. Compare girlies. ๐Ÿ’…

๐Ÿ‘‹ typedef void(* alpm_list_fn_free) (void *item) ๐Ÿ‘‹

Item deallocation callback. Say bye to an item. ๐Ÿซถ

Parameters

  • item โ€” the item to free. She's leaving the chat. ๐Ÿ’€

โœจ Function Documentation โœจ

okay so these are the functions, and yes, we're doing every single one. no skips, no cap. let's get into it ๐Ÿ’…


๐ŸŒธ alpm_list_t * alpm_list_add (alpm_list_t * list, void * data) ๐ŸŒธ

Adds a brand-new item to the end of the list. it's giving "the list said yes to plus-one energy."

Parameters

  • list โ€” the list to add to
  • data โ€” the new item to be added to the list

Returns

  • the resultant list

๐ŸŒธ alpm_list_t * alpm_list_add_sorted (alpm_list_t * list, void * data, alpm_list_fn_cmp fn) ๐ŸŒธ

Adds items to a list in sorted order. no chaos, just order, bestie.

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

๐ŸŒธ alpm_list_t * alpm_list_append (alpm_list_t ** list, void * data) ๐ŸŒธ

Adds a new item to the end of the list. this one is lowkey different from alpm_list_add because it hands you back the newly added item, not the whole list. main character energy for real.

Parameters

  • list โ€” the list to add to
  • data โ€” the new item to be added to the list

Returns

  • the newly added item

๐ŸŒธ alpm_list_t * alpm_list_append_strdup (alpm_list_t ** list, const char * data) ๐ŸŒธ

Duplicates a string and appends it to a list. it's giving "copy then attach, no cap."

Parameters

  • list โ€” the list to append to
  • data โ€” the string to duplicate and append

Returns

  • the newly added item

๐ŸŒธ int alpm_list_cmp_unsorted (const alpm_list_t * left, const alpm_list_t * right, alpm_list_fn_cmp fn) ๐ŸŒธ

Checks if two lists contain the same data, ignoring order. Lists are considered equal if they both contain the same data regardless of order. so order is not the vibe here, just the contents.

Parameters

  • left โ€” the first list
  • right โ€” the second list
  • fn โ€” the comparison function

Returns

  • 1 if the lists are equal, 0 if not equal, -1 on error. periodt.

๐ŸŒธ alpm_list_t * alpm_list_copy (const alpm_list_t * list) ๐ŸŒธ

Copies a list, without copying data. so the list structure is duplicated, but the data itself is not. iykyk.

Parameters

  • list โ€” the list to copy

Returns

  • a copy of the original list

๐ŸŒธ alpm_list_t * alpm_list_copy_data (const alpm_list_t * list, size_t size) ๐ŸŒธ

Copies a list and copies the data. note that the data elements to be copied should not contain pointers and should also be of constant size. so if your data is pointer-y or variable-size, this is not the one, bestie.

Parameters

  • list โ€” the list to copy
  • size โ€” the size of each data element

Returns

  • a copy of the original list, data copied as well

๐ŸŒธ size_t alpm_list_count (const alpm_list_t * list) ๐ŸŒธ

Gets the number of items in a list. it's the vibe check for how many besties are in the list.

Parameters

  • list โ€” the list

Returns

  • the number of list items

๐ŸŒธ alpm_list_t * alpm_list_diff (const alpm_list_t * lhs, const alpm_list_t * rhs, alpm_list_fn_cmp fn) ๐ŸŒธ

Finds the items in list lhs that are not present in list rhs. it's giving "what's in left but not right," periodt.

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

๐ŸŒธ 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) ๐ŸŒธ

Finds 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. so sorted vibes only, no cap.

Parameters

  • 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

๐ŸŒธ void * alpm_list_find (const alpm_list_t * haystack, const void * needle, alpm_list_fn_cmp fn) ๐ŸŒธ

Finds an item in a list. it's the classic haystack-and-needle situation, but make it C.

Parameters

  • needle โ€” the item to search
  • haystack โ€” the list
  • fn โ€” the comparison function for searching (!= NULL)

Returns

  • needle if found, NULL otherwise

๐ŸŒธ void * alpm_list_find_ptr (const alpm_list_t * haystack, const void * needle) ๐ŸŒธ

Finds an item in a list. searches for the item whose data matches that of the needle. it's an == comparison situation.

Parameters

  • needle โ€” the data to search for (== comparison)
  • haystack โ€” the list

Returns

  • needle if found, NULL otherwise

๐ŸŒธ char * alpm_list_find_str (const alpm_list_t * haystack, const char * needle) ๐ŸŒธ

Finds a string in a list. string search but make it alpm.

Parameters

  • needle โ€” the string to search for
  • haystack โ€” the list

Returns

  • needle if found, NULL otherwise

๐ŸŒธ void alpm_list_free (alpm_list_t * list) ๐ŸŒธ

Frees a list, but not the contained data. so the list says bye, but the data is still there. don't @ me.

Parameters

  • list โ€” the list to free

๐ŸŒธ void alpm_list_free_inner (alpm_list_t * list, alpm_list_fn_free fn) ๐ŸŒธ

Frees the internal data of a list structure but not the list itself. so it's the inner cleanup, not the whole breakup.

Parameters

  • list โ€” the list to free
  • fn โ€” a free function for the internal data

๐ŸŒธ alpm_list_t * alpm_list_join (alpm_list_t * first, alpm_list_t * second) ๐ŸŒธ

Joins 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. so like, they're married now, don't try to date them separately, bestie. ๐Ÿ’€

Parameters

  • first โ€” the first list
  • second โ€” the second list

Returns

  • the resultant joined list

๐ŸŒธ alpm_list_t * alpm_list_last (const alpm_list_t * list) ๐ŸŒธ

Gets the last item in the list. it's the final boss of the list.

Parameters

  • list โ€” the list

Returns

  • the last element in the list

๐ŸŒธ alpm_list_t * alpm_list_mmerge (alpm_list_t * left, alpm_list_t * right, alpm_list_fn_cmp fn) ๐ŸŒธ

Merges the two sorted sublists into one sorted list. it's giving merge energy, sorted and iconic.

Parameters

  • left โ€” the first list
  • right โ€” the second list
  • fn โ€” comparison function for determining merge order

Returns

  • the resultant list

๐ŸŒธ alpm_list_t * alpm_list_msort (alpm_list_t * list, size_t n, alpm_list_fn_cmp fn) ๐ŸŒธ

Sorts a list of size n using the mergesort algorithm. no cap, mergesort is the moment.

Parameters

  • list โ€” the list to sort
  • n โ€” the size of the list
  • fn โ€” the comparison function for determining order

Returns

  • the resultant list

๐ŸŒธ alpm_list_t * alpm_list_next (const alpm_list_t * list) ๐ŸŒธ

Gets the next element of a list. it's the "who's next" of list nodes.

Parameters

  • list โ€” the list node

Returns

  • the next element, or NULL when no more elements exist

๐ŸŒธ alpm_list_t * alpm_list_nth (const alpm_list_t * list, size_t n) ๐ŸŒธ

Returns the nth element from list (starting from 0). note: n < alpm_list_count(list) IS needed. so check your index, bestie, or it's not gonna work.

Parameters

  • list โ€” the list
  • n โ€” the index of the item to find (n < alpm_list_count(list) IS needed)

Returns

  • an alpm_list_t node for index n

๐ŸŒธ alpm_list_t * alpm_list_previous (const alpm_list_t * list) ๐ŸŒธ

Gets the previous element of a list. it's the "look back" energy.

Parameters

  • list โ€” the list head

Returns

  • the previous element, or NULL when no previous element exist

๐ŸŒธ alpm_list_t * alpm_list_remove (alpm_list_t * haystack, const void * needle, alpm_list_fn_cmp fn, void ** data) ๐ŸŒธ

Removes an item from the list. it's giving "bye, bestie" to one item.

Parameters

  • 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

Returns

  • the resultant list

๐ŸŒธ alpm_list_t * alpm_list_remove_dupes (const alpm_list_t * list) ๐ŸŒธ

Creates a new list without any duplicates. this does NOT copy data members. so it's a fresh list, but the data is still the same data. no cap.

Parameters

  • list โ€” the list to copy

Returns

  • a new list containing non-duplicate items

๐ŸŒธ alpm_list_t * alpm_list_remove_item (alpm_list_t * haystack, alpm_list_t * item) ๐ŸŒธ

Removes an item from the list. item is not freed; this is the responsibility of the caller. so you gotta clean up after yourself, bestie. don't leave that memory hanging.

Parameters

  • haystack โ€” the list to remove the item from
  • item โ€” the item to remove from the list

Returns

  • the resultant list

๐ŸŒธ alpm_list_t * alpm_list_remove_str (alpm_list_t * haystack, const char * needle, char ** data) ๐ŸŒธ

Removes a string from a list. string removal, but make it alpm.

Parameters

  • 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

Returns

  • the resultant list

๐ŸŒธ alpm_list_t * alpm_list_reverse (alpm_list_t * list) ๐ŸŒธ

Creates a new list in reverse order. it's giving "backwards but make it fashion."

Parameters

  • list โ€” the list to copy

Returns

  • a new list in reverse order

๐ŸŒธ alpm_list_t * alpm_list_strdup (const alpm_list_t * list) ๐ŸŒธ

Copies a string list, including data. so strings get duplicated too. periodt.

Parameters

  • list โ€” the list to copy

Returns

  • a copy of the original list

๐ŸŒธ void * alpm_list_to_array (const alpm_list_t * list, size_t n, size_t size) ๐ŸŒธ

Copies 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. so be careful with pointers, bestie, they're not cloned.

Parameters

  • list โ€” the list to copy
  • n โ€” the size of the list
  • size โ€” the size of each data element

Returns

  • an array version of the original list, data copied as well

โœจ Author โœจ

Generated automatically by Doxygen for libalpm from the source code.


๐Ÿ’– so that's the whole function documentation, bestie. source/version: libalpm ยท page: libalpm_list(3) ยท date: not shown in this footer, but the vibe is forever. mwah ๐Ÿ’‹

๐Ÿ“ฆ where this page comes from