[Serdev] Nested MySQL queries

Jan Janak jan at iptel.org
Mon Sep 19 18:22:23 UTC 2005


On 19-09-2005 19:59, Andreas Granig wrote:
> Jan Janak wrote:
> >The problem is that the conversion function does not allocate memory for 
> >strings and binary data, it just points to the memory region allocated by 
> >mysqlclient library. If you call mysql_free_result while the resulting 
> >(converted) data structures are still use then the pointers to strings and 
> >binary data would point to unallocated memory regions.
> 
> Oh, yes, haven't seen this and was surprised about the unexpected 
> results when trying it out a few minutes ago...
> 
> >You would need to make an explicit copy of all strings and binary data
> >before calling mysql_free_result (that would be slower).
> 
> Another possibility which is more elegant IMHO is storing the result in 
> a void-pointer in db_res_t, where it logically belongs to. Would this be 
> a passable solution?

  I don't know what is the internal structure of the data in mysqlclient
  library, the strings are zero terminated so most likely each of them
  has its own memory chunk.

    Jan.




More information about the Serdev mailing list