A memory buffer that the program allocates

If you want to handle your own memory allocation for simple large objects, use the malloc() system call to allocate the memory and then set the following fields in the locator structure:
  • Before a select or fetch of a TEXT or BYTE column, set the loc_buffer field to the address of the allocated memory buffer, and set the loc_bufsize field to the size of the memory buffer.
  • Before an insert of a TEXT or BYTE column, set the same fields as for a select or fetch. In addition, set loc_size to the size of the data to be inserted in the database.
If the fetched data does not fit in the allocated buffer, the Informix® ESQL/C libraries set loc_status (and SQLCODE) to a negative value (-451) and put the actual size of the data in loc_indicator. If the fetched data does fit, Informix ESQL/C sets loc_size to the size of the fetched data.
Important: When you allocate your own memory buffer, also free the memory when you are finished selecting or inserting simple large objects. Informix ESQL/C does not free this memory because it has no way to determine when you are finished with the memory. Because you have allocated the memory with malloc(), you can use the free() system call to free the memory.