NODEUPDOWN_NODELIST_CREATE(3)

πŸ“¦ version 1.14, in epel 9, fedora 43, fedora 44

πŸ’– NODEUPDOWN_NODELIST_CREATE πŸ’–

okay bestie, so this is the libnodeupdown girlies' guide to lists β€” like, actual C lists, arrays of strings, the whole thing. Three functions, one vibe: nodeupdown_nodelist_create, nodeupdown_nodelist_clear, and nodeupdown_nodelist_destroy. They make lists, they wipe lists, they yeet lists. Slay. ✨


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <nodeupdown.h>

int nodeupdown_nodelist_create(nodeupdown_t handle, char ***list);

int nodeupdown_nodelist_clear(nodeupdown_t handle, char **list);

int nodeupdown_nodelist_destroy(nodeupdown_t handle, char **list);

🌸 DESCRIPTION 🌸

so like, these three are your little list-management besties πŸ’… β€” they create, clear, and destroy lists (which are arrays of strings, btw) so you can use them with nodeupdown_get_up_nodes_list(3) and nodeupdown_get_down_nodes_list(3). that's the whole point of them, no cap.

nodeupdown_nodelist_create() makes a list with the minimum size needed to store nodes. list gets set to point at the list that just got created. and here's the pinky promise: the list it creates is guaranteed to store all the nodes that come back from nodeupdown_get_up_nodes_list(3) and nodeupdown_get_down_nodes_list(3). no overflow jumpscares, we love that for you. 🫢

nodeupdown_nodelist_clear() clears out whatever info is chilling in the list that list points to. important note bestie: you do not have to call this after nodeupdown_nodelist_create(). nope! it only has to be called after you've used the list with nodeupdown_get_up_nodes_list(3) or nodeupdown_get_down_nodes_list(3) and you wanna re-use that list. it's giving recycling era ♻️.

nodeupdown_nodelist_destroy() destroys the list that list points to and frees all the memory associated with it. it's the final boss of cleanup, the closure era, the "we're done here" text. πŸ’€


🌈 RETURN VALUES 🌈

okay so on success:

  • nodeupdown_nodelist_create() returns the number of elements the created list can store. like, the capacity, the whole flex. πŸ”₯
  • nodeupdown_nodelist_clear() and nodeupdown_nodelist_destroy() both return 0. iconic, consistent, we stan.

on error, -1 is returned, and an error code gets returned in handle. you can grab that error code via nodeupdown_errnum(3), and a lil description of it via nodeupdown_strerror(3). the error codes themselves live in nodeupdown.h, iykyk.


πŸ’€ ERRORS πŸ’€

vibe check on what could go wrong:

  • NODEUPDOWN_ERR_NULLHANDLE β€” the handle parameter is NULL. bestie you gotta create the nodeupdown handle with nodeupdown_handle_create(3) first, fr fr.
  • NODEUPDOWN_ERR_NOTLOADED β€” nodeupdown_load_data(3) has not been called and no data has been retrieved. nothing loaded, nothing to work with πŸ™ˆ.
  • NODEUPDOWN_ERR_PARAMETERS β€” an incorrect parameter has been passed in. wrong vibe, wrong arg.
  • NODEUPDOWN_ERR_NULLPTR β€” a null pointer has been found in the list passed in. found a stray NULL in there, not cute.
  • NODEUPDOWN_ERR_OUTMEM β€” malloc(3) has failed internally. the memory said no 😭.
  • NODEUPDOWN_ERR_ISFREE β€” all lists associated with handle have already been freed. they're gone, they've left the chat.
  • NODEUPDOWN_ERR_MAGIC β€” handle has an incorrect magic number. either handle doesn't point to a nodeupdown handle at all, or it got destroyed by nodeupdown_handle_destroy(3). the magic is not magic-ing. ✨🚫

πŸŽ€ FILES πŸŽ€

  • /usr/include/nodeupdown.h

πŸ‘‘ SEE ALSO πŸ‘‘

libnodeupdown(3), nodeupdown_handle_create(3), nodeupdown_load_data(3), nodeupdown_get_up_nodes_list(3), nodeupdown_get_down_nodes_list(3), nodeupdown_errnum(3), nodeupdown_strerror(3)


and that's the whole page bestie πŸ’– this lil manual came from LLNL, dated August 2003 β€” yes she's an elder but she's still serving, and she's part of LIBNODEUPDOWN. go forth and manage your lists responsibly. periodt. πŸ’…πŸ¦‹

πŸ“¦ where this page comes from