Function to release dynamic memory assigned by other C functions
Functions C that return a string (char *) use dynamic memory allocation to store the return string.
Once that string is not needed, the memory assigned to it must be released.
Since the memory allocation was made inside the C library, the LkFreeMemory function must be used to release that memory.
data
|
char*
|
|
pointer to the memory that must be released
|
char* readOpt = LkCreateReadOptions(TRUE, FALSE, FALSE, FALSE, FALSE);
char* result = LkRead(connectionInfo, &hasError, filename, recordIds, dictClause, readOpt, outputStringType, customVars, receiveTimeout);
// If you are not going to perform more Read operations with the same options,
// we will not need the readOpt string
LkFreeMemory(readOpt);
// When the result of the Read operation is not needed,
// the memory must be released
LkFreeMemory(result);
|