Does exist a function to free a MYSQL_FIELD pointer?
Posted by: María José González
Date: September 22, 2005 02:30AM

Hi,

my code has a memory leak when executing it, and I suspect it comes from a bad free of a MYSQL_FIELD pointer.

I could see that when you make a mysql_store_result, it allocs memory to the variable inside this function, and after that you must to call mysql_free_result to free this memory.

Does it runs in the same way with mysql_fetch_fields?. If the answer is yes, which one is that function??.

My code looks like:

int cols;
int i;
MYSQL_RES *res_set;
MYSQL_FIELD *f;

............. it doesn't matter

res_set = mysql_store_result(mysql);
cols=mysql_num_fields(res_set);
f = mysql_fetch_fields(res_set);

for(i=0;i<cols;i++)
{
....... no important for this problem
}

mysql_free_result(res_set);
res_set = NULL;

....... and end
}

Options: ReplyQuote


Subject
Views
Written By
Posted
Does exist a function to free a MYSQL_FIELD pointer?
1342
September 22, 2005 02:30AM


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.