List:General Discussion« Previous MessageNext Message »
From:Teresa A Narvaez Date:December 23 2004 4:39pm
Subject:mysql_fetch_lengths()
View as plain text  



We were running mysql 3.22.30 on an Tru 64 Alpha server OSF 4.0F.  We
recently upgraded to mysql 3.23.58 on the same server.

In the code fragment below, there is a memory leak at line 8 because
mysql_fetch_lenghts returns an array of unsigned long integers representing
the size of each column.  So, has the retun value of mysql_fetch_lengths()
been the same for mysql 3.22.30 and 3.23.58?

Thank you ,
-Teresa

----------
1. unsigned long *lengths;
2. unsigned int num_fields;
3. unsigned int i;
4. MYSQL_RES *result=NULL;

5. row = mysql_fetch_row(result);
6. if (row)
7. {
8.     len = malloc(sizeof(unsigned long) * mysql_num_fields(result));
9.     num_fields = mysql_num_fields(result);
10.    lengths = mysql_fetch_lengths(result);
11.    for(i = 0; i < num_fields; i++)
12.    {
13.         printf("Column %u is %lu bytes in length.\n", i, lengths[i]);
14.    }

15.    free(len)
16.}

Thread
mysql_fetch_lengths()Teresa A Narvaez23 Dec
  • Re: mysql_fetch_lengths()Dan Nelson23 Dec
Re: mysql_fetch_lengths()Teresa A Narvaez23 Dec
  • Re: mysql_fetch_lengths()Dan Nelson23 Dec
Re: mysql_fetch_lengths()Teresa A Narvaez23 Dec