Re: ESQL/C: describe question
Posted in 1994
>Date: Wed, 12 Jan 1994 10:34:11 +0100 (GMT+0100) >From: "Centr. Instytut Ochrony Pracy" <cinsop@frodo.nask.org.pl> >Subject: ESQL/C: describe question > >Hi to everyone, I am not too experienced with ESQL/C and there are some >there are some details I need to understand which don't seem to be >explained in the documentation: What exactly happens when $describe >usqlobj into udesc is executed? I know that udesc is set to point to ... >blah blah blah but is the pointed to struct sqlda statically allocated or >am I responsible for deallocating it? What about sqlvar member of struct >sqlda. Who allocates, deallocates it and when? > >Pawel Pietrusinski >Centralny Instytut Ochrony Pracy >cinsop@frodo.nask.org.pl Good questions. The struct sqlda is dynamically allocated as a single block of memory which looks like: +---------------------+ | sqld -- field count | +---------------------+ | sqlvar -- pointer |--\\ +---------------------+ | | sqlvar_struct[0] |<-/ | | +---------------------+ | sqlvar_struct[1] | | | +---------------------+ | sqlvar_struct[2] | | | +---------------------+ | ... | | | +---------------------+ Speaking as a user of ESQL/C, and not as an Informix employee... De-allocation of this space is a vexed subject for me, and without having the time to re-check my memory, I think the behaviour has changed at several releases, and I don't remember exactly which releases do what. However, I think that release 5.00 would release the space for you when you re-executed the DESCRIBE, and if you did the release for it, all hell broke loose in malloc() and friends. As far as I can tell, 5.01 expects you to release the memory, but that needs re-checking. I think 4.0x and 4.1x expected you to release the memory too, along with 2.10.03, 2.10.00, and other earlier versions. When I find time to sort out my main ESQL/C command interpreter, there is going to be a #define for FREE_DESCRIBED_SQLDA or something similar to handle the differences between versions. If you allocate space for the sqlvar_struct elements to point to, it is always your repsonsibility to release that space before re-using the sqlda structure pointer. Yours, Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>