Muokkaa

Jaa


NativeMemory.AlignedRealloc(Void*, UIntPtr, UIntPtr) Method

Definition

Important

This API is not CLS-compliant.

Reallocates an aligned block of memory of the specified size and alignment, in bytes.

public:
 static void* AlignedRealloc(void* ptr, UIntPtr byteCount, UIntPtr alignment);
[System.CLSCompliant(false)]
public static void* AlignedRealloc (void* ptr, nuint byteCount, nuint alignment);
[System.CLSCompliant(false)]
public static void* AlignedRealloc (void* ptr, UIntPtr byteCount, UIntPtr alignment);
[<System.CLSCompliant(false)>]
static member AlignedRealloc : nativeptr<unit> * unativeint * unativeint -> nativeptr<unit>

Parameters

ptr
Void*

The previously allocated block of memory.

byteCount
UIntPtr

nuint

unativeint

The size, in bytes, of the block to allocate.

alignment
UIntPtr

nuint

unativeint

The alignment, in bytes, of the block to allocate. This must be a power of 2.

Returns

Void*

A pointer to the reallocated aligned block of memory.

Attributes

Exceptions

alignment is not a power of two.

Reallocating byteCount of memory with alignment failed.

Remarks

This method acts as AlignedAlloc(UIntPtr, UIntPtr) if ptr is null.

This method allows byteCount to be 0 and will return a valid pointer that should not be dereferenced and that should be passed to free to avoid memory leaks.

This method is a platform dependent aligned reallocation API such as _aligned_realloc on Win32.

This method is not compatible with Free(Void*) or Realloc(Void*, UIntPtr). Instead, call AlignedFree(Void*) or AlignedRealloc(Void*, UIntPtr, UIntPtr).

Applies to