RtAllocateLocalMemoryEx

RtAllocateLocalMemoryEx allocates memory from the external memory allocation space (MSpace) of the current process. RtAllocateLocalMemoryEx allows you to allocate memory without zero-initializing the memory region.

Syntax

Copy
PVOID RtAllocateLocalMemoryEx(
    [in]    ULONG Size,
    [in]    ULONG Flags
);

Parameters

[in] Size

An unsigned long specifying the number of bytes to allocate.

[in] Flags

The memory allocation option. This parameter can be one or more of the following values:

Value Meaning

RTALLOC_NOT_ZERO_MEMORY

The allocated memory will not be initialized to zero. Otherwise, the memory will be initialized to zero if Zero memory at allocation is selected in wRTOS Settings.

Return Value

If the function succeeds, it returns a pointer to the memory. If the function fails, it returns a NULL pointer.

Remarks

RtAllocateLocalMemoryEx is a deterministic memory allocation call and can be called in a shutdown handler, provided the MSpace contains the requested memory.

Note: If the MSpace’s local pool has not been created yet or if the amount of free memory in the pool is not enough for the requested Size, there is Windows interaction involved in an RtAllocateLocalMemoryEx call and the deterministic feature is lost. To avoid that, call RtQueryProcessMSpace first to make sure there is enough free memory in the MSpace.

Note: If the MSpace’s local pool has not been created yet, RtAllocateLocalMemoryEx will initialize the pool with a size equal to the greater value of the Size parameter or the minimum size threshold configured via wRTOS Settings. If the amount of free memory in the pool is not enough for the requested Size, RtAllocateLocalMemoryEx will implicitly expand the pool with a size equal to the max{ MSpacePoolExpandSize, Size }. You can disable this implicitly expand feature overall through wRTOS Settings or individually by using RtssRun /e with nExpandSize equal to 0.

Requirements

Minimum supported version Header Library

wRTOS 1.0 SDK

RtssApi.h

Startup.lib

See Also: