Hi,

I tried taking out the new MYSQL, and my application dumps -- it doesn't look like mysql_init is actually allocating memory for the MYSQL object because then mysql_real_connect is called with a NULL pointer.

Is that supposed to happen?

--Anna

Ben Goodwin wrote:

Hi!
mysql_init will detect if 'mysql' is a NULL pointer or not and allocate
accordingly. However, your code below doesn't initialize 'mysql' that way,
so your results are undefined. I'd recommend:

MYSQL *mysql = NULL;

mysql_init (mysql);
mysql_real_connect(mysql, host, user, password, dbase, 0, 0, 0);

OR

MYSQL mysql;

mysql_init (&mysql);
mysql_real_connect(&mysql, host, user, password, dbase, 0, 0, 0);

-=| Ben


----- Original Message -----
From: "Anna Fowles-Winkler" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, November 19, 2002 2:58 PM
Subject: Does mysql_real_connect allocate memory?



Hi,

Does the MySQL C API function mysql_real connect allocate memory or do I
need to do it? This is what my code currently does:

MYSQL *mysql;
mysql = new MYSQL
mysql_init(mysql);
mysql_real_connect(mysql, host, user, password, dbase, 0, 0, 0);

Thanks,
Anna



---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail

<[EMAIL PROTECTED]>

Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php






---------------------------------------------------------------------
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to