Directional Attributes Applied to the Parameter

The directional attributes in and out determine how the client and server allocate and free memory. The following table summarizes the effect of directional attributes on memory allocation:

Directional attribute
Memory on client

Memory on server
in Client application must allocate before call. Server stub allocates.
out Client stub allocates on return. Server stub allocates top-level pointer only; server application must allocate all embedded pointers. Server also allocates new data as needed.
in, out Client application must allocate initial data transmitted to server; client stub allocates additional data. Server stub allocates; server application allocates new data as needed.

The following table summarizes the effect of directional attributes on memory deallocation:

Directional attribute
Memory on client

Memory on server
(all cases) Not freed. Freed by server stubs on return (subject to ACF attribute allocate).

Note that for out-only parameters, MIDL allocates only the memory required for the top-level pointer parameter. The generated stub does not chase, or dereference, subsequent pointers that are part of the out-only data structure. The server application must allocate and initialize all such pointers.