Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
4/8/2010

The MAPIFreeBufferfunction frees a memory buffer that was previously allocated with a call to either the MAPIAllocateBufferfunction, or the MAPIAllocateMorefunction.

Syntax

ULONG MAPIFreeBuffer(
  LPVOID 
lpBuffer 
);

Parameters

lpBuffer

[in] Pointer to a previously allocated memory buffer; if NULL, MAPIFreeBufferdoes nothing.

Return Value

S_OK

The call succeeded and freed the memory requested. MAPIFreeBuffercan also return S_OKon already freed locations or if memory block is not allocated with MAPIAllocateBufferand MAPIAllocateMore.

Remarks

Usually, when a client application or service provider calls MAPIAllocateBufferor MAPIAllocateMore, the operating system constructs in one contiguous memory buffer one or more complex structures with multiple levels of pointers. When a MAPI function or method creates a buffer with such contents, a client can later free all the structures contained in the buffer by passing to MAPIFreeBufferthe pointer to the buffer returned by the MAPI function that created the buffer. For a service provider to free a memory buffer using MAPIFreeBuffer, it must pass the pointer to that buffer returned with the provider's support object.

The call to MAPIFreeBufferto free a particular buffer must be made as soon as a client or provider is finished using this buffer.

A client or service provider should operate on the assumption that the pointer passed in lpBufferis not valid after a successful return from MAPIFreeBuffer. If the pointer indicates either a memory block not allocated by the messaging system through MAPIAllocateBufferor MAPIAllocateMoreor a free memory block, the behavior of MAPIFreeBufferis undefined.

Note:
Passing a null pointer to MAPIFreeBuffermakes application cleanup code simpler and smaller because MAPIFreeBuffercan initialize pointers to NULLand then free them in the cleanup code without having to test them first.

Requirements

Header mapix.h
Library cemapi.lib
Windows Embedded CE Windows CE 3.0 and later
Windows Mobile Pocket PC 2002 and later, Smartphone 2002 and later

See Also

Reference

MAPI Functions

Other Resources

Messaging