/
gmSCMemorySequenceClass

gmSCMemorySequenceClass

The MemorySequence Service Class

The service class MemorySequence manages memory based sequences. No matter how carefully an information system is laid out, to be persistent, there must ultimately be some variable length sequences of information vectors which must be stored in memory -- this can be symbol table information, virtual page control information, or whatever other set of information is needed.

A memory sequence consists of a set of ordered relatively short fixed-length records numbered from 1 to n, where n is the number of records in the set. They are completely memory based and have no upper limit other than that imposed by the platform limits. Conceptually, the records of a sequence are viewed as records within a linear vector with no upper bound. The algorithmic problem is that since multiple sequences must share the same linear addressing scheme, each sequence must be blocked, and the addresses of those blocks must be retained in higher level blocks.

The method MemorySequence_Access

Prototype


UBYTE* MemorySequence_Access(void* This,int uSequence);
The MemorySequence_Access method accesses a memory-based sequence. It returns a pointer to a slot in memory which contains a specific fixed length information vector, contained within a specified sequence and specified via its subscript or record number (relative to one) within that sequence. This method makes no attempt to check the specified record number for reasonableness. It assumes that no record is accessed before it has been created. If the next record in the sequence is desired, then pass a zero record number to this method. Its parameters are:

Parameter Description
This Specifies the handle of the control structure for the sequence as returned by the MemorySequence_Create method.
uSequence specifies the sequence number of the desired record or zero if a new record is to be added.

The only possible error condition that can be encountered by this method is insufficient memory to create a new block. If this occurs, then it returns a NULL; else it returns a pointer to the record whose number was specified.

The method MemorySequence_Create

Prototype


void* MemorySequence_Create(int iBlockSize,int iRecordSize);
The MemorySequence_Create method creates a memory-based sequence -- i.e., a memory-bound set of blocks containing of a sequence of relatively short fixed length records numbered from 1 to n, where n is the number of records in the set. Its parameters are:

Parameter Description
iBlockSize Specifies the size of each memory block to be used to store the actual records in the sequence and the control blocks needed to locate records by their record numbers.
iRecordSize specifies the size of each record stored in the sequence.

This method returns the handle to the control structure for the sequence or a NULL if the control structure cannot be created. The only possible cause of a create failure is insufficient memory available to the process.

The method MemorySequence_Destroy

Prototype


void MemorySequence_Destroy(void* This);
The MemorySequence_Destroy method destroys a memory-based sequence. It frees all memory associated with the sequence -- the record blocks, the record location blocks, and the control structure for the sequence itself. Its parameter is:

Parameter Description
This Specifies the handle of the control structure for the sequence as returned by the method MemorySequence_Create.

The method has no return value.

The method MemorySequence_GetSize

Prototype


int MemorySequence_GetSize(void* This);
The MemorySequence_GetSize method returns the size of a memory-based sequence -- i.e., the number of records in the sequence. Its parameter is:

Parameter Description
This Specifies the handle of the control structure for the sequence as returned by the method MemorySequence_Create.

The methods returns the number of records in the sequence.
Table of Contents