Re: Blobs n ESQL/C for Windows
Posted in 1996
In article <4l6oi7$c20@news2.delphi.com> TYNEELY@news.delphi.com (TYNEELY@DELPHI.COM) writes: >cse@wetware.com (Scott Ellard) writes: > >>In article <4l2l2j$s5m@news2.delphi.com> TYNEELY@news.delphi.com (TYNEELY@DELPHI.COM) writes: >>>I have a WFW 3.11 app that read/writes BLOBS to a Informix 5.x Online >>>engine using ESQL/C 5.01WE1 for Windows. The documentation for ESQL/C >>>say that if you pass in a -1 for your uffer size on a fetch Informix wil >>>allocate a buffer and return the size and a pointer to this buffer. When >>>does Informix actually release this buffer or is it up to my app? > >>It is up to your app. The memory was allocated using GlobalAllocPtr() >>and should be freed using GlobalFreePtr(). These are both macros found >>in <windowsx.h>. >>Scott >To follow up, the documentation(Informix ESQL/C for WIndows 5.01 6-5) >says that "If you do subsequent fetches and the amount of data selected >increases, the buffer is freed and the necessary memory is allocated". >What happens if I free and Informix comes around and tries to free it again? >thanks >--terry Don't free the memory until after you finish with the last fetch. Informix will grow the buffer as necessary on intervening fetches if and only if you told Informix to allocate the memory in the first place. On the other hand, if you allocated a 10k buffer and the blob was 11k, you will get a truncated indication. Informix does not reallocate your memory as it had no idea where your memory came from. Since there is no easy way to know how big a blob is prior to any given fetch, I usually let Informix handle my blob memory management. However, for specialized memory management, I have used the LOCUSER flag and implemented by own loc_open/read/write/close() methods. (see locator.h) Scott