Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

midl_user_allocate attribute

The midl_user_allocate function is a function that client and server applications provide to allocate memory.


void __RPC_FAR * __RPC_API midl_user_allocate (size_t cBytes);

Parameters

cBytes

Specifies the count of bytes to allocate.

Remarks

Both client applications and server applications must implement the midl_user_allocate function, unless you are compiling in OSF-compatibility (/osf) mode. Applications and generated stubs call midl_user_allocate when dealing with objects referenced by pointers:

  • The server application should call midl_user_allocate to allocate memory for the application—for example, when creating a new node.
  • The server stub calls midl_user_allocate when unmarshaling pointed-at data into the server address space.
  • The client stub calls midl_user_allocate when unmarshaling data from the server that is referenced by an out pointer. Note that for [in], [out], and [unique] pointers, the client stub calls midl_user_allocate only if the [unique] pointer value was NULL on input and changes to a non-NULL value during the call. If the [unique] pointer was non-NULL on input, the client stub writes the associated data into existing memory.

If midl_user_allocate fails to allocate memory, it must return a NULL pointer.

It is recommended that midl_user_allocate return a pointer that is 8 bytes aligned.

Examples


#include <windows.h>

void __RPC_FAR * __RPC_API midl_user_allocate(size_t cBytes) 
{ 
    return(malloc(cBytes)); 
}


See also

allocate
arrays
Arrays and Pointers
Array and Sized-Pointer Attributes
in
midl_user_free
/osf
out
ptr
ref
unique

 

 

Show:
© 2017 Microsoft