28 struct keydesc *pskeydesc,
const int imode,
const int iposn)
31 int ikeylength = pskeydesc->k_len;
32 int ilength, iposition, iresult;
35 if (!pstree || !pstree->
pskeylist[iposn]) {
46 if (pskeydesc->k_flags & ISDUPS) {
52 && ilength + 3 + ikeylength + idupslength +
QUADSIZE >=
59 iposition = INTSIZE +
QUADSIZE + (iposn * (ikeylength + idupslength +
QUADSIZE));
61 iposition = INTSIZE + (iposn * (ikeylength + idupslength +
QUADSIZE));
64 memmove (
cvbnodetmp + iposition + ikeylength + idupslength + QUADSIZE,
65 cvbnodetmp + iposition, (
size_t)(ilength - iposition));
67 if (pskeydesc->k_flags & ISDUPS) {
72 cvbnodetmp + iposition + ikeylength + idupslength);
74 if (ilength - (iposition + ikeylength + idupslength + QUADSIZE) > 0) {
76 cvbnodetmp + iposition + ikeylength + idupslength + QUADSIZE,
77 (
size_t)(ilength - (iposition + ikeylength + idupslength + QUADSIZE)));
79 memset (
cvbnodetmp + ilength - (ikeylength + QUADSIZE), 0,
80 (
size_t)(ikeylength + idupslength + QUADSIZE));
92 struct VBKEY *psrootkey[], off_t tnewnode1, off_t tnewnode2)
100 psrootkey[0]->
psnext = psrootkey[1];
101 psrootkey[1]->
psnext = psrootkey[2];
102 psrootkey[2]->
psprev = psrootkey[1];
103 psrootkey[1]->
psprev = psrootkey[0];
105 psrootkey[0]->
pschild = pstree;
106 psrootkey[1]->
pschild = psnewtree;
112 (
size_t)psvbptr->
pskeydesc[ikeynumber]->k_len);
134 psvbptr->
pstree[ikeynumber] = psroottree;
164 struct VBKEY *pskeyhalfway)
167 struct VBKEY *pskey, *pskeytemp, *psholdkeycurr, *psnewkey;
168 struct VBKEY *psrootkey[3];
170 off_t tnewnode1, tnewnode2 = 0;
204 if (tnewnode2 == -1) {
209 if (tnewnode1 == -1) {
215 pskey = pskeyhalfway->
psnext;
228 for (pskeytemp = pskey; pskeytemp; pskeytemp = pskeytemp->
psnext) {
231 return inewroot (ihandle, ikeynumber, pstree, psnewtree, psroottree, psrootkey,
232 tnewnode1, tnewnode2);
238 pskeyhalfway->
psnext = psnewkey;
239 psnewkey->
psprev = pskeyhalfway;
266 psholdkeycurr = psvbptr->
pskeycurr[ikeynumber];
273 psvbptr->
pskeycurr[ikeynumber] = psholdkeycurr;
289 struct VBKEY *pskey, *pskeynext;
290 struct keydesc *pskeydesc;
297 int idups = 0, inodelen, iresult;
298 unsigned char cprevkey[VB_MAX_KEYLEN];
299 unsigned char chighkey[VB_MAX_KEYLEN];
302 pskeydesc = psvbptr->
pskeydesc[ikeynumber];
309 if (iprevlvl != -1) {
326 for (pskey = pstree->
pskeyfirst; pskey; pskey = pskeynext) {
331 pskeynext = pskey->
psnext;
342 if (pskeydesc->k_flags & LCOMPRESS) {
345 pcnodeptr += INTSIZE;
347 icountlc = *(pcnodeptr);
351 if (pskeydesc->k_flags & TCOMPRESS) {
354 pcnodeptr += INTSIZE;
356 icounttc = *(pcnodeptr);
360 memcpy (cprevkey + icountlc, pcnodeptr,
361 (
size_t)(pskeydesc->k_len - (icountlc + icounttc)));
362 memset (cprevkey + pskeydesc->k_len - icounttc,
TCC, (
size_t)icounttc);
363 pcnodeptr += pskeydesc->k_len - (icountlc + icounttc);
365 if (pskeydesc->k_flags & ISDUPS) {
371 if (pskeydesc->k_flags & DCOMPRESS) {
372 if (*pcnodeptr & 0x80) {
391 memcpy (pskey->
ckey, cprevkey, (
size_t)pskeydesc->k_len);
395 memcpy (pstree->
pskeylast->
ckey, chighkey, (
size_t)pskeydesc->k_len);
417 const off_t tnodenumber,
const int imode,
const int iposn)
420 unsigned char *pckeyendptr, *pcnodeptr, *pcnodehalfway;
421 unsigned char *pcnodeend, *pcprevkey =
NULL;
422 struct VBKEY *pskey, *pskeyhalfway =
NULL;
423 struct keydesc *pskeydesc;
426 ilasttc = 0, ikeylen, imaxtc, iresult;
429 pskeydesc = psvbptr->
pskeydesc[ikeynumber];
444 if (imode && !(pskeydesc->k_flags & (DCOMPRESS | TCOMPRESS | LCOMPRESS))) {
445 if (
iquicknodesave (ihandle, pstree, tnodenumber, pskeydesc, imode, iposn) == 0) {
459 *pcnodeend = pstree->
ilevel;
466 if (pcnodeptr >= pcnodehalfway) {
467 pskeyhalfway = pskey->
psprev;
470 ikeylen = pskeydesc->k_len;
471 if (pskeydesc->k_flags & TCOMPRESS) {
474 pckeyendptr = pskey->
ckey + ikeylen - 1;
475 while (*pckeyendptr-- ==
TCC && pckeyendptr != pskey->
ckey) {
479 ikeylen += INTSIZE - icounttc;
481 ikeylen += 1 - icounttc;
484 if (pskeydesc->k_flags & LCOMPRESS) {
487 imaxtc = pskeydesc->k_len - (icounttc >
488 ilasttc ? icounttc : ilasttc);
489 for (; pskey->
ckey[icountlc] == pcprevkey[icountlc]
490 && icountlc < imaxtc; icountlc++) ;
493 ikeylen += INTSIZE - icountlc;
495 ikeylen += 1 - icountlc;
497 if (pskey->
iishigh && pskeydesc->k_flags && LCOMPRESS) {
498 icountlc = pskeydesc->k_len;
501 if (pskeydesc->k_flags && TCOMPRESS) {
502 ikeylen = INTSIZE * 2;
507 if (pskeydesc->k_flags && TCOMPRESS) {
513 if (pskeydesc->k_flags & DCOMPRESS) {
518 if (pskeydesc->k_flags & ISDUPS) {
522 && !memcmp (pskey->
ckey, pcprevkey, (
size_t)pskeydesc->k_len))) {
523 if (pskeydesc->k_flags & DCOMPRESS) {
530 if (pcnodeptr + ikeylen >= pcnodeend - 1) {
538 iresult =
inodesplit (ihandle, ikeynumber, pstree, pskeyhalfway);
542 && ((pskeydesc->k_flags & (DCOMPRESS | ISDUPS)) == (DCOMPRESS | ISDUPS)))
543 || (pskeydesc->k_flags & DCOMPRESS && !(pskeydesc->k_flags & ISDUPS)
547 if (pskeydesc->k_flags & LCOMPRESS) {
550 pcnodeptr += INTSIZE;
552 *pcnodeptr++ = icountlc;
555 if (pskeydesc->k_flags & TCOMPRESS) {
558 pcnodeptr += INTSIZE;
560 *pcnodeptr++ = icounttc;
563 if (icountlc != pskeydesc->k_len) {
564 pcprevkey = pskey->
ckey + icountlc;
565 imaxtc = pskeydesc->k_len - (icountlc + icounttc);
567 *pcnodeptr++ = *pcprevkey++;
570 pcprevkey = pskey->
ckey;
572 if (pskeydesc->k_flags & ISDUPS) {
static int inl_ldint(void *pclocation)
static char cvbnodetmp[4096]
void vvbkeyvalueset(const int ihigh, struct keydesc *pskeydesc, unsigned char *pckeyvalue)
struct VBTREE * psvbtreeallocate(const int ihandle)
int ivbblockread(const int ihandle, const int iisindex, const off_t tblocknumber, char *cbuffer)
struct VBKEY * psvbkeyallocate(const int ihandle, const int ikeynumber)
int ivbnodeload(const int ihandle, const int ikeynumber, struct VBTREE *pstree, const off_t tnodenumber, const int iprevlvl)
static int inodesplit(const int ihandle, const int ikeynumber, struct VBTREE *pstree, struct VBKEY *pskeyhalfway)
static void inl_stint(int ivalue, void *pclocation)
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
static int iquicknodesave(const int ihandle, struct VBTREE *pstree, const off_t tnodenumber, struct keydesc *pskeydesc, const int imode, const int iposn)
struct VBKEY * pskeycurr[32]
struct DICTNODE sdictnode
void vvbkeyfree(const int ihandle, const int ikeynumber, struct VBKEY *pskey)
struct DICTINFO * psvbfile[128+1]
int ivbkeyinsert(const int ihandle, struct VBTREE *pstree, const int ikeynumber, unsigned char *pckeyvalue, off_t trownode, off_t tdupnumber, struct VBTREE *pschild)
int ivbblockwrite(const int ihandle, const int iisindex, const off_t tblocknumber, const char *cbuffer)
void vvbtreeallfree(const int ihandle, const int ikeynumber, struct VBTREE *pstree)
struct VBKEY * pskeylist[512]
static void inl_stquad(off_t tvalue, void *pclocation)
int ivbnodesave(const int ihandle, const int ikeynumber, struct VBTREE *pstree, const off_t tnodenumber, const int imode, const int iposn)
struct VBTREE * pstree[32]
struct VBKEY * pskeyfirst
struct keydesc * pskeydesc[32]
static off_t inl_ldquad(void *pclocation)
static int inewroot(const int ihandle, const int ikeynumber, struct VBTREE *pstree, struct VBTREE *psnewtree, struct VBTREE *psroottree, struct VBKEY *psrootkey[], off_t tnewnode1, off_t tnewnode2)
off_t tvbnodeallocate(const int ihandle)