mysql_free_result(3)

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

mysql_free_result πŸ’– aka the lil cleanup queen

okay bestie, so this one is from the MariaDB Connector/C manual (yes, that's the whole manual family, we're in the C connector section πŸŽ€) and it's honestly one of the most important habits you can build. no cap.


✨ NAME ✨

mysql_free_result β€” frees result set πŸ¦‹

like, it releases the memory. that's the whole job. she's simple, she's iconic, she's necessary.


🌸 SYNOPSIS 🌸

#include <mysql.h>

void mysql_free_result(MYSQL_RES * result);

look at her. one line. no return value. no drama. periodt.


πŸ’… DESCRIPTION πŸ’…

so mysql_free_result frees the memory associated with a result set.

that's it. that's the function. it returns void, meaning it gives you literally nothing back β€” no status code, no error, no little note saying "hey bestie I did it". it just does the thing and dips. 🫢


πŸŽ€ PARAMETERS πŸŽ€


πŸ’€ NOTES πŸ’€

  • you should always free your result set with mysql_free_result() as soon as it's not needed anymore. not "later", not "when I remember", not "at the end of the program, probably". as soon as it's not needed. your memory will thank you, your future self will thank you, everyone wins. πŸ’–
  • this one is important so I'm gonna say it loud: row values you got from a prior mysql_fetch_row(3) call will become invalid after you call mysql_free_result(). like, the memory is gone. those pointers are pointing at nothing. if you try to read them after this, that's on you and it's not gonna be cute. 😭 copy what you need before you free.
ngl this is the #1 thing people mess up. free the result, then wonder why their strings are cursed. bestie. the strings are gone. that's the whole point. πŸ™ˆ

🌈 SEE ALSO 🌈


Version 3.4 of the MariaDB Connector/C manual, babes β€” go forth, free your result sets, and be the main character with zero memory leaks. πŸ’œβœ¨πŸ‘‘

πŸ“¦ where this page comes from