IORangeAllocator



Member Functions

allocate

Abstract: Allocate from the free list, at any offset.
public:

virtual bool allocate( IORangeScalar size, IORangeScalar * result, IORangeScalar alignment = 0 );

This method allocates a range from the free list. The alignment will default to the alignment set when the allocator was created or may be set here.

Parameters

NameDescription
sizeThe size of the range requested.
resultThe beginning of the range allocated is returned here on success.
alignmentIf zero is passed, default to the allocators alignment, otherwise pass an alignment required for the allocation, for example 4096 to page align.
Result: True if the allocation was successful, else false.

allocateRange

Abstract: Allocate from the free list, at a set offset.
public:

virtual bool allocateRange( IORangeScalar start, IORangeScalar size );

This method allocates a range from the free list, given a set offset passed in.

Parameters

NameDescription
startThe beginning of the range requested.
sizeThe size of the range requested.
Result: True if the allocation was successful, else false.

deallocate

Abstract: Deallocate a range to the free list.
public:

virtual void deallocate( IORangeScalar start, IORangeScalar size );

This method deallocates a range to the free list, given a the start offset and length passed in.

Parameters

NameDescription
startThe beginning of the range requested.
sizeThe size of the range requested.

getFragmentCapacity

Abstract: Accessor to return the number of free fragments in the range.
public:

virtual UInt32 getFragmentCapacity( void );

This method returns the current capacity of the free fragment list.

Result: The current capacity of free fragment list.

getFragmentCount

Abstract: Accessor to return the number of free fragments in the range.
public:

virtual UInt32 getFragmentCount( void );

This method returns a count of free fragments. Each fragment describes a non-contiguous free range - deallocations will merge contiguous fragments together.

Result: The count of free fragments.

getFreeCount

Abstract: Totals the sizes of the free fragments.
public:

virtual IORangeScalar getFreeCount( void );

This method returns the total of the sizes of the fragments on the free list.

Result: The total of the free fragments sizes.

init

Abstract: Standard initializer for IORangeAllocator.
public:

virtual bool init( IORangeScalar endOfRange, IORangeScalar defaultAlignment, UInt32 capacity, IOOptionBits options );

This method initializes an IORangeAllocator and optionally sets the free list to contain one fragment, from zero to an endOfRange parameter. The capacity in terms of free fragments and locking options are set for the instance.

Parameters

NameDescription
endOfRangeIf the free list is to contain an initial fragment, set endOfRange to the last offset in the range, ie. size - 1, to create a free fragment for the range zero to endOfRange inclusive. If zero is passed the free list will be initialized empty, and can be populated with calls to the deallocate method.
defaultAlignmentIf this parameter is non-zero it specifies a required alignment for all allocations, for example pass 256 to align allocations on 256 byte boundaries. Zero or one specify unaligned allocations.
capacitySets the initial size of the free list in number of non-contiguous fragments. This value is also used for the capacityIncrement.
optionsPass kLocking if the instance can be used by multiple threads.
Result: Returns true if the instance is successfully initialize, false on failure.

setFragmentCapacityIncrement

Abstract: Sets the count of fragments the free list will increase by when full.
public:

virtual void setFragmentCapacityIncrement( UInt32 count );

This method sets the number of extra fragments the free list will expand to when full. It defaults to the initial capacity.

Parameters

NameDescription
countThe number of fragments to increment the capacity by when the free list is full.

withRange

Abstract: Standard factory method for IORangeAllocator.
public:

static IORangeAllocator * withRange( IORangeScalar endOfRange, IORangeScalar defaultAlignment = 0, UInt32 capacity = 0, IOOptionBits options = 0 );

This method allocates and initializes an IORangeAllocator and optionally sets the free list to contain one fragment, from zero to an endOfRange parameter. The capacity in terms of free fragments and locking options are set for the instance.

Parameters

NameDescription
endOfRangeIf the free list is to contain an initial fragment, set endOfRange to the last offset in the range, ie. size - 1, to create a free fragment for the range zero to endOfRange inclusive. If zero is passed the free list will be initialized empty, and can be populated with calls to the deallocate method.
defaultAlignmentIf this parameter is non-zero it specifies a required alignment for all allocations, for example pass 256 to align allocations on 256 byte boundaries. Zero or one specify unaligned allocations.
capacitySets the initial size of the free list in number of non-contiguous fragments. This value is also used for the capacityIncrement.
optionsPass kLocking if the instance can be used by multiple threads.
Result: Returns the new IORangeAllocator instance, to be released by the caller, or zero on failure.

© 2000 Apple Computer, Inc. — (Last Updated 2/23/2000)