I have the following code:

 

        //try the mysql connection

        mysql_init(&mysql_connection);

        if(!mysql_real_connect(&mysql_connection, db_host, db_user, db_pass,
db_db, 0, NULL, 0)) {

                flockfile(stderr);

                fprintf(stderr, "%s: Failed to connect to database: Error:
%s\n", timestamp, mysql_error(&mysql_connection));

                funlockfile(stderr);

                mysql_close(&mysql_connection);

                return(2);

        }

 

        mysql_close(&mysql_connection);

 

This code is creating a memory leak.  Am I missing some cleanup calls? I'm
under the impression all I should need to do is call mysql_close to clean up
the connection?  I'm testing this using mtrace, if I place a return directly
above the code segment it reports no leaks, if I place it direcly below the
fragment there are several variables reported as not being freed.  Any
ideas?

 

John A. McCaskey

 

Reply via email to