Export (0) Print
Expand All

IMalloc::Alloc method

Allocates a block of memory.

Syntax


void* Alloc(
  [in]  SIZE_T cb
);

Parameters

cb [in]

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—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

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

ObjIdl.h

IDL

ObjIdl.idl

IID

IID_IMalloc is defined as 00000002-0000-0000-C000-000000000046

See also

CoTaskMemAlloc
IMalloc

 

 

Community Additions

ADD
Show:
© 2015 Microsoft