IMalloc::Alloc method (objidl.h)

Allocates a block of memory.

Syntax

void * Alloc(
  [in] SIZE_T cb
);

Parameters

[in] cb

The size of the memory block to be allocated, in bytes.

Return value

If the method succeeds, the return value is a pointer to the allocated block of memory. Otherwise, it is NULL.

Applications should always check the return value from this method, even when requesting small amounts of memory, because there is no guarantee the memory will be allocated.

Remarks

The initial contents of the returned memory block are undefined and there is no guarantee that the block has been initialized, so you should initialize it in your code. The allocated block may be larger than cb bytes because of the space required for alignment and for maintenance information.

If cb is zero, Alloc allocates a zero-length item and returns a valid pointer to that item. If there is insufficient memory available, Alloc returns NULL.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header objidl.h

See also

CoTaskMemAlloc

IMalloc