Releasing Memory with CMC

In some circumstances, you will have to release memory that has been allocated by CMC. CMC provides a single function, cmc_free, for releasing memory that it has allocated. This memory is typically the result of a CMC function call. For example, the cmc_look_up function allocates an array of CMC_recipient structures to hold the results of an address book search. You are responsible for calling the cmc_free function on that array after it is no longer needed. To free memory allocated by CMC, pass a pointer to the memory to the cmc_free function.

A client should not try to free the memory itself. The memory is not guaranteed to be in a single contiguous block, so one call to an underlying memory management function — such as the C run time library function malloc — is not guaranteed to free all of the memory that CMC has allocated. A memory leak will result if you do this. The cmc_free function will make all the necessary memory management calls to properly free the memory CMC has allocated.