HEAP_ReAllocByStr

<< Click to Display Table of Contents >>

Navigation:  ThinBASIC Core Language > BuiltIn Functions > Memory handling and pointers > Heap memory >

HEAP_ReAllocByStr

 

Description

 

Re-allocates a block of memory from a heap removing a previous memory pointer.

 

The size of the block is the size of the passed string.

pMem pointer is de-allocated, the passed string is copied into a new memory block.

If the function succeeds, the return value is a pointer to the new allocated memory block.

 

Syntax

 

ptr = HEAP_ReAllocByStr(pMem, String [, AllowEmptyStringAllocation])

 

Returns

 

Number: pointer to the allocated memory area.

If returned value is zero, an error has occurred.

 

Parameters

 

Name

Type

Optional

Meaning

pMem

Number

No

Pointer to a heap memory to be de-allocated

String

String

No

String data to be allocated

AllowEmptyStringAllocation

Number

Yes

If this parameter is omitted or %FALSE, no memory allocation will take place if String is empty. In this case 0 (zero) will be returned.

If this parameter is %TRUE, a memory block will be allocated in any case even if String will be empty.

 

Remarks

 

This function works like HEAP_Free and HEAP_AllocByStr in one step

 

Restrictions

 

If an empty string is passed, no memory allocation will take place unless AllowEmptyStringAllocation is %TRUE.

 

See also

 

Examples