QMFree()

QMFree()

Top  Previous  Next

 

The QMFree() function releases memory returned by other functions. It is only used with the C API library.

 

The function takes one argument, Addr, as the memory address of the area to be released.

 

void QMFree(void * Addr)

 

Many of the C API functions return dynamically allocated memory. The QMFree() function allows a program to release this. The C runtime library free() function should not be used as it may not be compatible with the memory allocator used within the API functions.

 

To simplify application design where errors may lead to null pointers being returned by QMClient functions, passing a null pointer into QMFree() has no effect.

 

 

Example

 

Rec = QMReadu(fClients, ClientNo, TRUE, Err);

Rec2 = QMReplace(Rec, 1, Pos, 0, NewData);

QMWrite(fClients, ClientNo, Rec2);

QMFree(Rec);

QMFree(Rec2);

 

The above program fragment reads a record with an update lock, modifies it and then writes it back to the file. A real program should test the Err status from the read operation to determine if it was successful. The QMFree() is used to release the dynamic memory allocated to store Rec and Rec2.