SAFE_ADD_ID_TO_LIST(3)

πŸ“¦ version 1.0.5, in nixos 26.05, nixpkgs unstable

πŸ’… safe_add_id_to_list β€” the SAFE_ADD_ID_TO_LIST(3) glow-up πŸŽ€

okay bestie, so this is a page from section 3 of the manual (that's the library-functions girlies), and it's literally just two little functions whose whole job is adding ids to a list. no cap, that's it. but they do it safely, which is the whole vibe ✨


πŸ¦‹ NAME

  • safe_add_id_to_list, safe_add_id_range_to_list β€” add an id, or a whole range of ids, to the list πŸ’–

🌸 SYNOPSIS

#include "safe_id_range_list.h"

struct safe_id_range_list;
typedef struct safe_id_range_list safe_id_range_list;

int safe_add_id_to_list(safe_id_range_list list, id_t id);
int safe_add_id_range_to_list(safe_id_range_list list, id_t min_id, id_t
max_id);

so yes, you include "safe_id_range_list.h", the struct is an opaque-ish struct safe_id_range_list with a typedef so you don't have to type struct every single time (we love a convenience king πŸ‘‘), and then you've got your two little adders up there ☝️


πŸ”₯ DESCRIPTION

safe_add_id_to_list adds a single id to list. one id. that's the whole plot. iconic, minimal, no notes 🫢

safe_add_id_range_to_list adds a range of ids to list. and here's the rule, bestie, listen up: the min_id must be less than or equal to max_id. that's not a suggestion, that's the law πŸ’€


πŸ’œ Parameters

  • list β€” the safe_id_range_list you're adding values to. it must be non-NULL β€” like, fr fr, do not hand this a NULL, that's not the move πŸ™ˆ
  • id β€” the id you wanna add. that's it, that's the arg πŸ“
  • min_id, max_id β€” the range of ids to add. and again, because we don't play around here: the min_id must be less than or equal to the max_id ⭐

✨ RETURN VALUE

returns 0 on success and -1 on failure, with errno set appropriately. so like, 0 = slay, -1 = check your errno, bestie, it's gonna tell you what went wrong πŸ”


πŸ’€ ERRORS

  • EINVAL β€” the list parameter was NULL, or, in safe_add_id_range_list, min_id was greater than max_id. yeah. that's the "you did the thing" error 😭
  • ENOMEM β€” failed to allocate memory. the memory said no 🫠

🧚 AUTHOR

James A. Kupsch β€” the legend who wrote all this πŸ’– (we stan)


🌈 SEE ALSO

and if you want more of this energy:

http://research.cs.wisc.edu/mist/safefile


okay that's the whole page, you ate that 🍽️✨ this was SAFE_ADD_ID_TO_LIST(3), dated 2011-07-26 β€” a certified classic, still serving looks on section 3 πŸ’…πŸŽ€

πŸ“¦ where this page comes from