Free memory allocated to an sqlda structure

Once you finish with an sqlda structure, free the associated memory. If you execute multiple DESCRIBE statements and you neglect to free the memory allocated by these statements, your application might run into memory constraints and the database server might exit.

If your application runs on a Windows™ operating system and uses the multi-threading library, use the function SqlFreeMem() to release the memory that the sqlda structure occupies as in this example:
SqlFreeMem(sqlda_ptr, SQLDA_FREE);
Otherwise, use the standard C library free() function, as shown in this example:
free(sqlda_ptr);
If your program executes a DESCRIBE statement multiple times for the same prepared statement and allocates a separate sqlda structure for each DESCRIBE, it must explicitly deallocate each sqlda structure. The following figure shows an example.
Figure 1: Deallocating multiple sqlda structures for the same prepared statement
EXEC SQL prepare qid from 'select * from customer';
EXEC SQL describe qid into sqldaptr1;
EXEC SQL describe qid into sqldaptr2;
EXEC SQL describe qid into sqldaptr3;
;
free(sqldaptr1);
free(sqldaptr2);
free(sqldaptr3);

If your program allocated space for column data, you must also deallocate the memory allocated to the sqldata fields.