memory/ allocator.bi

Summary
memory/ allocator.bi
LicenseCopyright © 2009, FreeBASIC Extended Library Development Group
ext
fbext_Allocator((T_))Macro template that generates the default allocator class for use with T_ objects.
Functions
constructorConstructs an allocator object.
constructorConstructs an allocator object from another.
destructorDestructs the allocator object.
AllocateAcquires memory for an array of n number of T_ objects.
DeAllocateFrees the memory of the array starting at the address p, which contains n number of T_ objects.
ConstructCopy constructs an object at address p with value.
DestroyDestroys the object at address p by calling its destructor.

License

Copyright © 2009, FreeBASIC Extended Library Development Group

Distributed under the FreeBASIC Extended Library Group license.  See accompanying file LICENSE.txt or copy at http://code.google.com- /p- /fb-extended-lib- /wiki- /License

ext

fbext_Allocator((T_))

Macro template that generates the default allocator class for use with T_ objects.

Parameters

T_the type of object that is allocated and constructed.

This is the default allocator used in many portions of the FreeBASIC Extended Library.  It uses New[] and Delete[] to allocate and deallocate memory for objects.

Summary
Functions
constructorConstructs an allocator object.
constructorConstructs an allocator object from another.
destructorDestructs the allocator object.
AllocateAcquires memory for an array of n number of T_ objects.
DeAllocateFrees the memory of the array starting at the address p, which contains n number of T_ objects.
ConstructCopy constructs an object at address p with value.
DestroyDestroys the object at address p by calling its destructor.

Functions

constructor

declare constructor ( )

Constructs an allocator object.

constructor

declare constructor (byref x as const fbext_Allocator((T_)))

Constructs an allocator object from another.  The new allocator object can deallocate memory allocated by the other allocator object, and vice-versa.

destructor

declare destructor ( )

Destructs the allocator object.

Allocate

declare function Allocate (
   byval n as SizeType,  
   byval hint as fbext_TypeName(T_) ptr =  0
) as fbext_TypeName(T_) ptr

Acquires memory for an array of n number of T_ objects.

Parameters

nthe number of objects in the array.
hintignored.

Returns

Returns the address of the first object in the array.

DeAllocate

declare sub DeAllocate (byval p as fbext_TypeName(T_) ptr,
byval n as SizeType)

Frees the memory of the array starting at the address p, which contains n number of T_ objects.

Parameters

pthe address of the first object.
nthe number of objects contained within the memory.

Construct

declare sub Construct (byval p as fbext_TypeName(T_) ptr,
byref value as const fbext_TypeName(T_))

Copy constructs an object at address p with value.

Parameters

pthe address of the object to construct.
valuethe value to construct the object with.

Destroy

declare sub Destroy (byval p as fbext_TypeName(T_) ptr)

Destroys the object at address p by calling its destructor.

Parameters

pthe address of the object to destroy.
declare constructor ( )
Constructs an allocator object.
declare destructor ( )
Destructs the allocator object.
declare function Allocate (
   byval n as SizeType,  
   byval hint as fbext_TypeName(T_) ptr =  0
) as fbext_TypeName(T_) ptr
Acquires memory for an array of n number of T_ objects.
declare sub DeAllocate (byval p as fbext_TypeName(T_) ptr,
byval n as SizeType)
Frees the memory of the array starting at the address p, which contains n number of T_ objects.
declare sub Construct (byval p as fbext_TypeName(T_) ptr,
byref value as const fbext_TypeName(T_))
Copy constructs an object at address p with value.
declare sub Destroy (byval p as fbext_TypeName(T_) ptr)
Destroys the object at address p by calling its destructor.