Documentation Home
MySQL 5.6 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 31.4Mb
PDF (A4) - 31.5Mb
PDF (RPM) - 30.6Mb
EPUB - 7.8Mb
HTML Download (TGZ) - 7.6Mb
HTML Download (Zip) - 7.6Mb
HTML Download (RPM) - 6.5Mb
Eclipse Doc Plugin (TGZ) - 8.3Mb
Eclipse Doc Plugin (Zip) - 10.2Mb
Man Pages (TGZ) - 185.3Kb
Man Pages (Zip) - 298.0Kb
Info (Gzip) - 2.9Mb
Info (Zip) - 2.9Mb
Excerpts from this Manual mysql_free_result()

void mysql_free_result(MYSQL_RES *result)


Frees the memory allocated for a result set by mysql_store_result(), mysql_use_result(), mysql_list_dbs(), and so forth. When you are done with a result set, you must free the memory it uses by calling mysql_free_result().

Do not attempt to access a result set after freeing it.

Return Values




User Comments
  Posted by mickey on January 19, 2004
mysql_free_result() free the MYSQL_RES, but it didn't set result to NULL. When we want to check result in other code, we can set result as default NULL where after call mysql_free_result(), and Set result as default NULL before store it.


MYSQL mysql;
res = NULL; // Set res as default NULL

mysql_query(&mysql,"SELECT * FROM person WHERE no<\'10\'");
res = mysql_store_result(&mysql);
..... other code here.....
... maybe check res is NULL or not
res = NULL; // Set res as default NULL

// Notes:
If result is NULL, we call mysql_free_result(res) is ok.
If call mysql_free_result(res) more once, we can get an memory access error.

res = mysql_store_result(&mysql);
mysql_free_result(res); // call free result once
res = NULL;
mysql_free_result(res); // call free result more then once is ok, because we set res as default NULL when after call mysql_free_result()

res = mysql_store_result(&mysql);
mysql_free_result(res); // must call free result once
mysql_free_result(res); // call free result more then once is BAD, because res is unallocated now.

Sign Up Login You must be logged in to post a comment.