cs_destroy(3)

πŸ’– cs_destroy β€” bestie, it's cleanup time πŸ’–

okay so this is a page from the cs/cs.h manual (section 3, library calls, iykyk) and it's all about the one function that every good parse tree eventually needs: cs_destroy. she frees things. she's the friend who helps you pack up after the party. iconic behavior honestly. 🧹✨


✨ NAME ✨

cs_destroy β€” clean up and dealloc a parse tree 🫢


🌸 SYNOPSIS 🌸

#include <cs/cs.h>

void cs_destroy (CSPARSE **parse);

πŸŽ€ ARGUMENTS πŸŽ€

  • parse β€” a pointer to a parse structure. yes bestie, a pointer to a pointer. she's fancy like that. πŸ’…

πŸ¦‹ DESCRIPTION πŸ¦‹

so cs_destroy will clean up all the memory associated with a CSPARSE structure, including strings passed to cs_parse_string. full send. no leftovers. the whole vibe gets deallocated. ✨

but wait β€” a couple of things she does not touch, and this matters:

  • she does not clean up any memory allocated by your own CSOUTFUNC πŸ‘€
  • she does not clean up the HDF data structure passed to cs_init πŸ‘€

those are yours, bestie. you handle those. she's not your mom.

and here's the cute part: it is safe to call this with a NULL pointer, and it will leave parse NULL as well β€” ie, it can be called more than once on the same var. so no need to stress about double-calling, she's literally built for it. πŸ’–


🌈 RETURN VALUE 🌈

  • parse β€” will be NULL. that's it. that's the whole return value. she leaves it NULL and dips. πŸ‘‘

⭐ SEE ALSO ⭐

the whole friend group, no cap:


lowkey important reminder: cs_destroy frees the strings you handed to cs_parse_string, but your CSOUTFUNC memory and your cs_init HDF structure are your responsibility. don't make her do your chores. πŸ™ˆ

and that's the whole page bestie!! this one's from the ClearSilver girlies, dated 12 July 2007 β€” yeah she's an elder but she still slays πŸ’œπŸŽ€

cs_destroy(3) β€” periodt. πŸ’…βœ¨