00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef _VSET_H_
00035 #define _VSET_H_
00036
00037 #include <maloc/maloc_base.h>
00038
00039 #include <maloc/vnm.h>
00040 #include <maloc/vmem.h>
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 typedef struct Vset {
00055
00056 Vmem *vmem;
00057 int iMadeVmem;
00058
00059 int curT;
00060
00061 char nameT[80];
00062 int sizeT;
00063
00064 int numBlocks;
00065 int numT;
00066 int prtT;
00067
00068 int maxObjects;
00069 int blockPower;
00070 int blockSize;
00071 int blockMax;
00072 int blockModulo;
00073
00074 char **table;
00075
00076 } Vset;
00077
00078
00079
00080
00081
00082
00083
00084 #if !defined(VINLINE_MALOC)
00085 int Vset_num(Vset *thee);
00086 char *Vset_access(Vset *thee, int i);
00087 char *Vset_create(Vset *thee);
00088 char *Vset_first(Vset *thee);
00089 char *Vset_last(Vset *thee);
00090 char *Vset_next(Vset *thee);
00091 char *Vset_prev(Vset *thee);
00092 char *Vset_peekFirst(Vset *thee);
00093 char *Vset_peekLast(Vset *thee);
00094 void Vset_destroy(Vset *thee);
00095 #else
00096 # define Vset_num(thee) ((thee)->numT)
00097 # define Vset_access(thee,i) ( \
00098 ((i >= 0) && (i < thee->numT)) \
00099 ? &((thee)->table[ (i)>>(thee)->blockPower ] \
00100 [ (thee)->sizeT*((i)&(thee)->blockModulo) ]) \
00101 : VNULL \
00102 )
00103 # define Vset_create(thee) ( \
00104 ( ((((thee)->numT)>>(thee)->blockPower) >= (thee)->numBlocks) \
00105 || ((((thee)->numT+1)%(thee)->prtT) == 0) ) \
00106 ? (Vset_createLast((thee))) \
00107 : (++((thee)->numT), (Vset_access((thee),(thee)->numT-1))) \
00108 )
00109 # define Vset_first(thee) ( \
00110 (thee)->curT = 0, \
00111 Vset_access((thee), (thee)->curT) \
00112 )
00113 # define Vset_last(thee) ( \
00114 (thee)->curT = (thee)->numT-1, \
00115 Vset_access((thee), (thee)->curT) \
00116 )
00117 # define Vset_next(thee) ( \
00118 (thee)->curT++, \
00119 ((thee)->curT < (thee)->numT) \
00120 ? Vset_access((thee), (thee)->curT) \
00121 : VNULL \
00122 )
00123 # define Vset_prev(thee) ( \
00124 (thee)->curT--, \
00125 ((thee)->curT >= 0) \
00126 ? Vset_access((thee), (thee)->curT) \
00127 : VNULL \
00128 )
00129 # define Vset_peekFirst(thee) ( \
00130 Vset_access((thee), 0) \
00131 )
00132 # define Vset_peekLast(thee) ( \
00133 Vset_access((thee), (thee)->numT-1) \
00134 )
00135 # define Vset_destroy(thee) ( \
00136 ( ((((thee)->numT-1)>>(thee)->blockPower) < (thee)->numBlocks-1) \
00137 || ((thee)->numT == 1) || ((((thee)->numT)%(thee)->prtT) == 0) ) \
00138 ? (Vset_destroyLast((thee))) : (void)(((thee)->numT)--) \
00139 )
00140 #endif
00141
00142
00143
00144
00145
00146
00147
00148 Vset* Vset_ctor(Vmem *vmem,
00149 const char *tname, int tsize, int tmaxNum, int ioKey);
00150 void Vset_dtor(Vset **thee);
00151
00152 char *Vset_createLast(Vset *thee);
00153 void Vset_destroyLast(Vset *thee);
00154 void Vset_initData(Vset *thee);
00155 void Vset_reset(Vset *thee);
00156 void Vset_check(Vset *thee,
00157 int *tnum, int *tsize, int *tVecUse, int *tVecMal, int *tVecOhd);
00158
00159 void Vset_memChk(Vset *thee);
00160
00161 #endif
00162
00163