vset.h
Go to the documentation of this file.
#ifndef _VSET_H_
#define _VSET_H_
#include <maloc/maloc_base.h>
#include <maloc/vnm.h>
#include <maloc/vmem.h>
/*
* ***************************************************************************
* Class Vset: Parameters and datatypes
* ***************************************************************************
*/
struct sVset {
Vmem *vmem;
int iMadeVmem;
int curT;
char nameT[VMAX_ARGLEN];
int sizeT;
int numBlocks;
int numT;
int prtT;
int maxObjects;
int blockPower;
int blockSize;
int blockMax;
int blockModulo;
char **table;
};
typedef struct sVset Vset;
/****************************************************************/
/* Class Vset: Inlineable method (vset.c) */
/****************************************************************/
#if !defined(VINLINE_MALOC)
int Vset_num(Vset *thee);
char *Vset_access(Vset *thee, int i);
char *Vset_create(Vset *thee);
char *Vset_first(Vset *thee);
char *Vset_last(Vset *thee);
char *Vset_next(Vset *thee);
char *Vset_prev(Vset *thee);
char *Vset_peekFirst(Vset *thee);
char *Vset_peekLast(Vset *thee);
void Vset_destroy(Vset *thee);
#else /* if defined(VINLINE_MALOC) */
# define Vset_num(thee) ((thee)->numT)
# define Vset_access(thee,i) ( \
((i >= 0) && (i < thee->numT)) \
? &((thee)->table[ (i)>>(thee)->blockPower ] \
[ (thee)->sizeT*((i)&(thee)->blockModulo) ]) \
: VNULL \
)
# define Vset_create(thee) ( \
( ((((thee)->numT)>>(thee)->blockPower) >= (thee)->numBlocks) \
|| ((((thee)->numT+1)%(thee)->prtT) == 0) ) \
? (Vset_createLast((thee))) \
: (++((thee)->numT), (Vset_access((thee),(thee)->numT-1))) \
)
# define Vset_first(thee) ( \
(thee)->curT = 0, \
Vset_access((thee), (thee)->curT) \
)
# define Vset_last(thee) ( \
(thee)->curT = (thee)->numT-1, \
Vset_access((thee), (thee)->curT) \
)
# define Vset_next(thee) ( \
(thee)->curT++, \
((thee)->curT < (thee)->numT) \
? Vset_access((thee), (thee)->curT) \
: VNULL \
)
# define Vset_prev(thee) ( \
(thee)->curT--, \
((thee)->curT >= 0) \
? Vset_access((thee), (thee)->curT) \
: VNULL \
)
# define Vset_peekFirst(thee) ( \
Vset_access((thee), 0) \
)
# define Vset_peekLast(thee) ( \
Vset_access((thee), (thee)->numT-1) \
)
# define Vset_destroy(thee) ( \
( ((((thee)->numT-1)>>(thee)->blockPower) < (thee)->numBlocks-1) \
|| ((thee)->numT == 1) || ((((thee)->numT)%(thee)->prtT) == 0) ) \
? (Vset_destroyLast((thee))) : (void)(((thee)->numT)--) \
)
#endif /* if !defined(VINLINE_MALOC) */
Vset* Vset_ctor(Vmem *vmem,
const char *tname, int tsize, int tmaxNum, int ioKey);
void Vset_dtor(Vset **thee);
char *Vset_createLast(Vset *thee);
void Vset_destroyLast(Vset *thee);
void Vset_initData(Vset *thee);
void Vset_reset(Vset *thee);
void Vset_check(Vset *thee,
int *tnum, int *tsize, int *tVecUse, int *tVecMal, int *tVecOhd);
void Vset_memChk(Vset *thee);
#endif /* _VSET_H_ */
maloc_base.h
The base (or foundation) header for MALOC.
VMAX_ARGLEN
#define VMAX_ARGLEN
Global constant.
Definition maloc_base.h:227
vnm.h
Header file for an ISO C [V]irtual [N]umerical [M]achine.
vmem.h
Class Vmem: A safer, object-oriented, malloc/free object.
Vmem
struct sVmem Vmem
Declaration of the Vmem class as the Vmem structure.
Definition vmem.h:73
Vset_peekFirst
char * Vset_peekFirst(Vset *thee)
Return the first object in the set.
Vset_prev
char * Vset_prev(Vset *thee)
Return the prev object in the set.
Vset
struct sVset Vset
Declaration of the Vset class as the Vset structure.
Definition vset.h:100
Vset_dtor
void Vset_dtor(Vset **thee)
Destroy the set object.
Vset_first
char * Vset_first(Vset *thee)
Return the first object in the set.
Vset_ctor
Vset * Vset_ctor(Vmem *vmem, const char *tname, int tsize, int tmaxNum, int ioKey)
Construct the set object.
Vset_reset
void Vset_reset(Vset *thee)
Release all Ram controlled by this (thee) and re-initialize.
Vset_next
char * Vset_next(Vset *thee)
Return the next object in the set.
Vset_initData
void Vset_initData(Vset *thee)
Initialize the Vset data (thee).
Vset_destroyLast
void Vset_destroyLast(Vset *thee)
Free up the object currently on the end of the list.
Vset_create
char * Vset_create(Vset *thee)
Create an object on the end of the list.
Vset_memChk
void Vset_memChk(Vset *thee)
Print the exact current malloc usage.
Vset_check
void Vset_check(Vset *thee, int *tnum, int *tsize, int *tVecUse, int *tVecMal, int *tVecOhd)
Get and return the RAM Control Block (thee) information.
Vset_num
int Vset_num(Vset *thee)
Return the number of things currently in the list.
Vset_peekLast
char * Vset_peekLast(Vset *thee)
Return the last object in the set.
Vset_last
char * Vset_last(Vset *thee)
Return the last object in the set.
Vset_destroy
void Vset_destroy(Vset *thee)
Delete an object from the end of the list.
Vset_createLast
char * Vset_createLast(Vset *thee)
Create an object on the end of the list.
Vset_access
char * Vset_access(Vset *thee, int i)
Access an object in an arbitrary place in the list.
sVset
Contains public data members for Vset class.
Definition vset.h:57
sVset::blockModulo
int blockModulo
=blockSize-1; for determining which block fast
Definition vset.h:88
sVset::nameT
char nameT[VMAX_ARGLEN]
name of object we are managing
Definition vset.h:68
sVset::iMadeVmem
int iMadeVmem
did i make vmem or was it inherited
Definition vset.h:62
sVset::blockSize
int blockSize
blocksize is 2^(blockPower)
Definition vset.h:84
sVset::table
char ** table
list of pointers to blocks of storage we manage
Definition vset.h:91
sVset::numBlocks
int numBlocks
total number of allocated blocks
Definition vset.h:73
sVset::prtT
int prtT
for i/o at appropriate block creation/deletion
Definition vset.h:77
sVset::vmem
Vmem * vmem
the memory manager
Definition vset.h:60
sVset::curT
int curT
the current "T" object in our collection
Definition vset.h:65
sVset::blockMax
int blockMax
num blocks = blockMax=(maxObjects/blockSize)
Definition vset.h:86
sVset::sizeT
int sizeT
size of the object in bytes
Definition vset.h:70
sVset::blockPower
int blockPower
power of 2 for blocksize (e.g., =10, or =16)
Definition vset.h:82
sVset::maxObjects
int maxObjects
number of objects to manage (user specified)
Definition vset.h:80
sVset::numT
int numT
the global "T" counter – how many "T"s in list
Definition vset.h:75