mysql_free_result(3)
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 π
resultβ a result set identifier. you get one of these frommysql_store_result(3)ormysql_use_result(3). that's your girl. hand her over and she gets tidied up. β¨
π 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 callmysql_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
- alpine 3.22: mariadb-doc 11.4.13-r0 Β· GPL-2.0-or-later
- alpine 3.23: mariadb-doc 11.4.13-r0 Β· GPL-2.0-or-later
- alpine 3.24: mariadb-doc 11.8.9-r0 Β· GPL-2.0-only
- arch rolling: mariadb 13.0.2-2 Β· GPL-2.0-only
- arch rolling: mariadb-lts 12.3.3-2 Β· GPL-2.0-only
- centos-stream 10: mariadb-connector-c-doc 3.4.4-2.el10 Β· LGPL-2.1-or-later
- debian trixie: libmariadb-dev 1:11.8.6-0+deb13u1 Β· GPL-2.0-only
- fedora 43: mariadb-connector-c-doc 3.4.5-2.fc43 Β· LGPL-2.1-or-later AND PHP-3.0 AND PHP-3.01
- fedora 43: mariadb-connector-c-doc 3.4.9-2.fc43 Β· LGPL-2.1-or-later AND PHP-3.0 AND PHP-3.01 AND LicenseRef-Fedora-Public-Domain
- fedora 44: mariadb-connector-c-doc 3.4.8-3.fc44 Β· LGPL-2.1-or-later AND PHP-3.0 AND PHP-3.01
- fedora 44: mariadb-connector-c-doc 3.4.9-2.fc44 Β· LGPL-2.1-or-later AND PHP-3.0 AND PHP-3.01 AND LicenseRef-Fedora-Public-Domain
- nixpkgs unstable: mariadb-server 11.8.8
- opensuse-leap 16.0: libmariadb-devel 3.4.9-160000.1.1 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: libmariadb-devel 3.4.9-160000.1.1 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: libmariadb-devel 3.4.9-160000.1.1 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: libmariadb-devel 3.4.9-160000.1.1 Β· LGPL-2.1-or-later
- ubuntu questing: libmariadb-dev 1:11.8.3-1build1
- ubuntu resolute: libmariadb-dev 1:11.8.6-5 Β· GPL-2.0-only
- ubuntu resolute: libmariadb-dev 1:11.8.6-5ubuntu0.1 Β· GPL-2.0-only
- ubuntu stonking: libmariadb-dev 1:11.8.9+ds-4ubuntu2 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms