Re: ECPG: FETCH ALL|n FROM cursor - Memory allocation?
От | Michael Meskes |
---|---|
Тема | Re: ECPG: FETCH ALL|n FROM cursor - Memory allocation? |
Дата | |
Msg-id | 20020425130713.GC10341@feivel.credativ.de обсуждение исходный текст |
Ответ на | ECPG: FETCH ALL|n FROM cursor - Memory allocation? (Lee Kindness <lkindness@csl.co.uk>) |
Список | pgsql-interfaces |
On Thu, Apr 25, 2002 at 12:42:00PM +0100, Lee Kindness wrote: > Assuming the following fetch statement in embedded SQL/C: > > EXEC SQL FETCH ALL IN selectFromTable_cur INTO > :array1, > :array2; > > is memory automatically allocated (by experimentation I guess so)? Only if the pointers are NULL. If they have a value libecpg assumes that this value points to enough memory to store all data. > Should the input pointers be NULL initialised? How should the memory > be freed? A simple free() will do. You also can free all automatically allocated memory from the most recent executed statement by calling ECPGfree_auto_mem(). But this is not documented and will never be. The correct way is to free(array1) and free(array2) while libecpg will free the internal structures when the next statement is executed. Michael -- Michael Meskes Michael@Fam-Meskes.De Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!
В списке pgsql-interfaces по дате отправления: