ARES_FREE_HOSTENT(3)

πŸ“¦
version 1.34.9 Β· 4 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– ARES_FREE_HOSTENT πŸ’–

okay bestie, so this one is from the ares library β€” Library Functions Manual energy, and it's genuinely one of the easiest little pages you'll ever read. the whole job? free the host structure. that's it. that's the gig. she's a one-trick pony and she eats every time. πŸ’…


✨ NAME ✨

ares_free_hostent β€” free the host structure that the ares functions allocated πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <ares.h>

void ares_free_hostent(struct hostent *host)

okay so like. that's the whole signature. one pointer, no return value, no drama. struct hostent *host goes in, nothing comes out. iconique. πŸ‘‘


🌸 DESCRIPTION 🌸

so here's the tea: ares_free_hostent frees a struct hostent that was allocated by one of these three besties:

if one of those gave you a host struct, and you're done with it, this is the function that hands it back. no cap. 🫢


πŸ’€ NOTES πŸ’€

okay this part is IMPORTANT, so like, actually read it, bestie, i'm begging πŸ™ˆ

it is not necessary β€” and lowkey not correct β€” to free the host structure that gets passed to the callback functions for ares_gethostbyname(3) or ares_gethostbyaddr(3).

⚠️ do NOT free that one. c-ares will automatically free those host structures itself when the callback returns. it's giving "i got this, mind your business." if you free it anyway you're double-freeing and that's a whole mess you do not want. 😭

so to recap the vibe check: parser-allocated host struct β†’ you free it βœ…, callback-allocated host struct β†’ hands off, c-ares frees it ❌. iykyk. ✨


🌈 SEE ALSO 🌈


and that's the whole page, bestie!! πŸŽ€βœ¨ this little cutie has been serving since 23 July 1998 (yes she's older than us and still slaying, main character energy fr fr), and it lives in the ARES_FREE_HOSTENT(3) corner of the library functions manual. go free your host structs responsibly. periodt. πŸ’–πŸ¦‹πŸ‘‘