WsAlloc function (webservices.h)

Allocates a segment of memory from the specified heap.

Syntax

HRESULT WsAlloc(
  WS_HEAP  *heap,
  SIZE_T   size,
  void     **ptr,
  WS_ERROR *error
);

Parameters

heap

Pointer to a WS_HEAP structure representing the heap from which to allocate the memory.

size

The number of bytes to allocate. This value can be zero.

ptr

On success, a pointer that receives the address of the allocated memory. This pointer is valid until WsFreeHeap or WsResetHeap is called on the heap.

The returned pointer is aligned on an 8-byte boundary.

Zero byte allocations will return a non-NULL pointer.

error

Pointer to a WS_ERROR structure that receives additional error information if the function fails.

Return value

If the function succeeds, it returns NO_ERROR; otherwise, it returns an HRESULT error code.

Return code Description
WS_E_QUOTA_EXCEEDED
The requested bytes, in addition to already allocated bytes, exceed the size of the heap, as specified by the WS_HEAP_PROPERTY_MAX_SIZE property.
E_OUTOFMEMORY
Insufficent memory to complete the operation.

Remarks

The memory returned by this function is not zero initialized and contains undefined values.

Requirements

   
Minimum supported client Windows 7 [desktop apps | UWP apps]
Minimum supported server Windows Server 2008 R2 [desktop apps | UWP apps]
Target Platform Windows
Header webservices.h
Library WebServices.lib
DLL WebServices.dll