mysql_init(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_init(3) πŸ’–

okay bestie, welcome to the MariaDB Connector/C manual, page mysql_init(3). this is literally the very first thing you call before you do anything cute with a MySQL/MariaDB connection, so let's get into it 🫢


✨ NAME ✨

mysql_init β€” prepares and initializes a MYSQL structure. that's it, that's the job, and it does it flawlessly πŸ’…


🌸 SYNOPSIS 🌸

#include <mysql.h>

MYSQL *mysql_init(MYSQL *mysql);

πŸ¦‹ DESCRIPTION πŸ¦‹

so like, mysql_init() prepares and initializes a MYSQL structure so it's ready to be used with mysql_real_connect(3). think of it as getting your little connection object dressed and ready for the main event ✨

and here's the cute part β€” it depends on what you pass in:

  • if you passed the address of a MYSQL structure as the parameter, that structure gets initialized, no questions asked πŸ’œ
  • if you passed NULL, a brand new structure gets allocated and initialized for you. slay, it does the memory work so you don't have to πŸŽ€

πŸŽ€ Notes πŸŽ€

bestie, read these. they're lowkey important.
  • if the parameter mysql is not NULL, the mysql_close(3) API function will not release the memory 😭 keep track of that yourself, no cap.
  • any subsequent calls to any function (except mysql_optionsv(3)) will fail until mysql_real_connect(3) was called. yeah, you heard me. don't go calling random stuff before you connect, it's giving impatience πŸ™ˆ
  • memory allocated by mysql_init() must be freed with mysql_close(3). periodt. free your memory, it's the responsible main character move πŸ‘‘

🌈 RETURN VALUE 🌈

mysql_init() returns the address of a MYSQL structure ✨ or NULL in case of a memory allocation error πŸ’€ (yes, that's a real thing that can happen, and now you know).


⭐ SEE ALSO ⭐


and that's the whole page bestie, you ate that πŸ“

this was Version 3.4 of the MariaDB Connector/C manual, page mysql_init(3) β€” mwah, go initialize something iconic πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…πŸ«Ά

πŸ“¦ where this page comes from