The largest free block that can be returned form
malloc() cannot be
determined. Therefore, the property
largestFreeSize in
Memory.Stats returned from
getStats() always returns
0.
config HeapStd_A_invalidAlignment // module-wide |
|
Assert that the alignment argument in alloc is valid
extern const Assert_Id HeapStd_A_invalidAlignment;
DETAILS
If this assertion is raised, it means that the requested alignment is
greater than the maximum alignment allowed on the target.
config HeapStd_A_invalidTotalFreeSize // module-wide |
|
Assert that remaining size is less than or equal to starting size
extern const Assert_Id HeapStd_A_invalidTotalFreeSize;
DETAILS
If this assertion is raised, it means that either incorrect sizes
were passed to
free or multiple calls to
free
were made with the same buffer.
config HeapStd_A_zeroSize // module-wide |
|
Assert that the size is non-zero on the create
config HeapStd_E_noRTSMemory // module-wide |
|
Error raised if all the RTS heap is used up
extern const Error_Id HeapStd_E_noRTSMemory;
DETAILS
The total size of all
HeapStd instance allocations added together
cannot exceed the
malloc/
free heap size determined by
xdc.cfg.Program.heap.
Module-Wide Built-Ins |
|
// Get this module's unique id
Bool HeapStd_Module_startupDone();
// Test if this module has completed startup
// The heap from which this module allocates memory
Bool HeapStd_Module_hasMask();
// Test whether this module has a diagnostics mask
Bits16 HeapStd_Module_getMask();
// Returns the diagnostics mask for this module
Void HeapStd_Module_setMask(Bits16 mask);
// Set the diagnostics mask for this module
Instance Object Types |
|
typedef struct HeapStd_Object HeapStd_Object;
// Opaque internal representation of an instance object
// Client reference to an instance object
typedef struct HeapStd_Struct HeapStd_Struct;
// Opaque client structure large enough to hold an instance object
// Convert this instance structure pointer into an instance handle
// Convert this instance handle into an instance structure pointer
Instance Config Parameters |
|
typedef struct HeapStd_Params {
// Instance config-params structure
// Common per-instance configs
// Size (in MAUs) of the heap
} HeapStd_Params;
// Initialize this config-params structure with supplier-specified defaults before instance creation
config HeapStd_size // instance |
|
Size (in MAUs) of the heap
DETAILS
This parameter specifies the size of the heap managed by a
HeapStd instance. HeapStd is built upon the ANSI C Standard
Library functions malloc() and free().
The total size of all
HeapStd instance allocations added together
cannot exceed the
malloc/
free heap size determined by
Program.heap.
This is a required parameter. It must be set by the caller. Failure
to do so, will result in a build error for the static create or an
assert for the runtime create.
Instance Creation |
|
// Allocate and initialize a new instance object and return its handle
// Initialize a new instance object inside the provided structure
ARGUMENTS
params
per-instance config params, or NULL to select default values (target-domain only)
eb
active error-handling block, or NULL to select default policy (target-domain only)
DETAILS
This heap uses the ANSI C Standard Library functions
malloc() and free() to manage memory and assumes that these
functions are thread-safe.
SEE
Instance Deletion |
|
// Finalize and free this previously allocated instance object, setting the referenced handle to NULL
// Finalize the instance object inside the provided structure
HeapStd_alloc() // instance |
|
Allocates a block of memory from the heap
ARGUMENTS
handle
handle of a previously-created HeapStd instance object
size
size (in MADUs) of the block
align
alignment (in MADUs) of the block
eb
pointer to error block
DETAILS
This method returns a block of memory from the heap.
It is called by the
xdc.runtime.Memory.alloc() function.
RETURNS
Returns the address of the allocated memory.
CONSTRAINTS
The only alignment currently supported is the default
alignment returned by the underlying
malloc() implementation.
The align value must be less than or equal to the value returned from
Memory.getMaxDefaultTypeAlign().
SEE
HeapStd_free() // instance |
|
Free a block of memory back to the heap
ARGUMENTS
handle
handle of a previously-created HeapStd instance object
block
non-NULL address of allocated block to free
size
size (in MADUs) of the block of memory to free
DETAILS
This method gives back a block of memory to a heap.
It is called by the
xdc.runtime.Memory.free() function.
HeapStd_getStats() // instance |
|
Retrieve the statistics from the heap
ARGUMENTS
handle
handle of a previously-created HeapStd instance object
stats
non-NULL pointer to an output buffer
DETAILS
The caller passes in a pointer to a
xdc.runtime.Memory.Stats
structure and
getStats fills in this structure.
This function is called by the
xdc.runtime.Memory.getStats()
function.
HeapStd_isBlocking() // instance |
|
Returns whether the heap may block during an HeapStd_alloc() or
HeapStd_free()
ARGUMENTS
handle
handle of a previously-created HeapStd instance object
RETURNS
If the heap might block, TRUE is returned.
If the heap does not block, FALSE is returned.
Since the implementation of the underlaying ANSI C Standard Library
is not known, this function always returns the more restrictive case
which is TRUE.
Instance Convertors |
|
// unconditionally move one level up the inheritance hierarchy
// conditionally move one level down the inheritance hierarchy; NULL upon failure
Instance Built-Ins |
|
Int HeapStd_Object_count();
// The number of statically-created instance objects
// The handle of the i-th statically-created instance object (array == NULL)
// The handle of the first dynamically-created instance object, or NULL
// The handle of the next dynamically-created instance object, or NULL
// The heap used to allocate dynamically-created instance objects
// The label associated with this instance object
// The name of this instance object
config HeapStd.A_invalidAlignment // module-wide |
|
Assert that the alignment argument in alloc is valid
XDCscript usage |
meta-domain |
msg: "HeapStd_alloc - requested alignment is greater than allowed"
};
DETAILS
If this assertion is raised, it means that the requested alignment is
greater than the maximum alignment allowed on the target.
C SYNOPSIS
config HeapStd.A_invalidTotalFreeSize // module-wide |
|
Assert that remaining size is less than or equal to starting size
XDCscript usage |
meta-domain |
msg: "HeapStd instance totalFreeSize is greater than starting size"
};
DETAILS
If this assertion is raised, it means that either incorrect sizes
were passed to
free or multiple calls to
free
were made with the same buffer.
C SYNOPSIS
config HeapStd.A_zeroSize // module-wide |
|
Assert that the size is non-zero on the create
XDCscript usage |
meta-domain |
msg: "HeapStd_create cannot have a zero size value"
};
C SYNOPSIS
config HeapStd.E_noRTSMemory // module-wide |
|
Error raised if all the RTS heap is used up
XDCscript usage |
meta-domain |
msg: "The RTS heap is used up. Examine Program.heap."
};
DETAILS
The total size of all
HeapStd instance allocations added together
cannot exceed the
malloc/
free heap size determined by
xdc.cfg.Program.heap.
C SYNOPSIS
metaonly config HeapStd.common$ // module-wide |
|
Common module configuration parameters
XDCscript usage |
meta-domain |
DETAILS
All modules have this configuration parameter. Its name
contains the '$' character to ensure it does not conflict with
configuration parameters declared by the module. This allows
new configuration parameters to be added in the future without
any chance of breaking existing modules.
Instance Config Parameters |
|
XDCscript usage |
meta-domain |
var params = new HeapStd.Params;
// Instance config-params object
params.size = UArg 0;
// Size (in MAUs) of the heap
config HeapStd.size // instance |
|
Size (in MAUs) of the heap
XDCscript usage |
meta-domain |
var params = new HeapStd.Params;
...
params.size = UArg 0;
DETAILS
This parameter specifies the size of the heap managed by a
HeapStd instance. HeapStd is built upon the ANSI C Standard
Library functions malloc() and free().
The total size of all
HeapStd instance allocations added together
cannot exceed the
malloc/
free heap size determined by
Program.heap.
This is a required parameter. It must be set by the caller. Failure
to do so, will result in a build error for the static create or an
assert for the runtime create.
C SYNOPSIS
Instance Creation |
|
XDCscript usage |
meta-domain |
var params =
new HeapStd.
Params;
// Allocate instance config-params
params.config = ...
// Assign individual configs
var inst = HeapStd.create(params);
// Create an instance-object
ARGUMENTS
params
per-instance config params, or NULL to select default values (target-domain only)
eb
active error-handling block, or NULL to select default policy (target-domain only)
DETAILS
This heap uses the ANSI C Standard Library functions
malloc() and free() to manage memory and assumes that these
functions are thread-safe.
SEE