2005/9/24, Lefteris Tsintjelis <[EMAIL PROTECTED]>:
> Hi,
>
> I have been searching for this for a while without finding a
> good answer.
>
> In the following example, MUST I call mysql_free_result() in
> case mysql_store_result(sql)==NULL or not?
>
> Is the following valid in case of NULL?
>
> query="update/insert ..."
>
> if (mysql_query(sql,query)!=0)
>         return(-1);
> if(mysql_store_result(sql)==NULL)
>         return(0);
> else {
>         ...
> }

if you do that, you don't retrieve your result since you don't set any
variable with it

if ( (res = mysql_store_result(...))==NULL ){
                //no result set (update,delete, insert, wrong select...)
                return 0;
if ( res ){
      mysql_free_result(res);
       res = NULL;
}


So you have to call a mysql_store_result for a select statement, but
otherwise, you don't have to. And if mysql_store_result return null
there is nothing to free, but you have to check for errors. (if you
fre that null pointer, what do you think will happens ?)
http://dev.mysql.com/doc/mysql/en/mysql-store-result.html

> mysql_free_result(result);
>
> Thnx,
>
> Lefteris
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]
>
>


--
Pooly
Webzine Rock : http://www.w-fenec.org/

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to