Skip navigation links

MySQL Forums :: C/C++ :: strange problem using mysql_free_result() ...


Advanced Search

Re: strange problem using mysql_free_result() ...
Posted by: Keith Kirton ()
Date: January 18, 2010 03:01AM

Hi Michael

I ran into a similar problem with this function today. I'm not sure if you've sorted it out already?
I'm guessing so though, as this post is 5 weeks old.

But what I discovered is this:

if(mysql_real_query(db,query,strlen(query)))
{
aff_str("Error making query: \n");
aff_str_ln(mysql_error(db));
}
my_res = mysql_store_result(db);

If your query fails do not attempt to store the result in your MYSQL_RES object.
This also then removes the need to call mysql_free_result() on the result object.

So rather do something like this:

if(mysql_real_query(db,query,strlen(query)))
{
aff_str("Error making query: \n");
aff_str_ln(mysql_error(db));

return failCode; //Just bail out and do nothing further.
}

My problem was, I consistently crashed at the same spot if I attempted to free a result set which actually had no proper "result" to free.

I hope this helps, for you and also for anyone else out there who may run into the same problem.

Regards.

PS. I see you call free(query) on your query object, this shouldn't be necessary as you haven't dynamically allocated that memory.
Just in case you think bailing out of function before calling that would be an issue.

Options: ReplyQuote


Subject Written By Posted
strange problem using mysql_free_result() ... Michael gibon 12/06/2009 08:22PM
Re: strange problem using mysql_free_result() ... Keith Kirton 01/18/2010 03:01AM
Re: strange problem using mysql_free_result() ... Michael gibon 01/18/2010 08:40PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.