static bool tchdbsavefbp(TCHDB *hdb) {
assert(hdb);
bool err = false;
-// if (!HDBLOCKDB(hdb)) return false;
if (hdb->fbpnum > hdb->fbpmax) {
tchdbfbpmerge(hdb);
} else if (hdb->fbpnum > 1) {
base = noff;
cur++;
}
-// HDBUNLOCKDB(hdb);
*(wp++) = '\0';
*(wp++) = '\0';
if (!tchdbseekwrite(hdb, hdb->msiz, buf, wp - buf)) {
return;
}
__atomic_add_fetch(&hdb->dfcnt, 1, __ATOMIC_RELEASE);
-// if (!HDBLOCKDB(hdb)) {
-// return;
-// }
HDBFB *pv = hdb->fbpool;
if (hdb->fbpnum >= hdb->fbpmax * HDBFBPALWRAT) {
tchdbfbpmerge(hdb);
pv->off = off;
pv->rsiz = rsiz;
hdb->fbpnum++;
-// HDBUNLOCKDB(hdb);
}
/* Search the free block pool for the minimum region.
static bool tchdbfbpsearch(TCHDB *hdb, TCHREC *rec) {
assert(hdb && rec);
TCDODEBUG(hdb->cnt_searchfbp++);
-// if (!HDBLOCKDB(hdb)) {
-// return false;
-// }
if (hdb->fbpnum < 1) {
rec->off = hdb->fsiz;
rec->rsiz = 0;
-// HDBUNLOCKDB(hdb);
return true;
}
uint32_t rsiz = rec->rsiz;
rec->rsiz = pv->rsiz;
memmove(pv, pv + 1, sizeof (*pv) * (num - cand - 1));
hdb->fbpnum--;
-// HDBUNLOCKDB(hdb);
return true;
}
rec->off = hdb->fsiz;
tchdbfbpmerge(hdb);
tcfbpsortbyrsiz(hdb->fbpool, hdb->fbpnum);
}
-// HDBUNLOCKDB(hdb);
return true;
}
if (tchdbseekread2(hdb, off, &magic, sizeof (magic), HDBSEEKTRY) && magic != HDBMAGICFB) {
return false;
}
- //if (!HDBLOCKDB(hdb)) return false;
HDBFB *pv = hdb->fbpool;
HDBFB *ep = pv + hdb->fbpnum;
while (pv < ep) {
rec->rsiz += pv->rsiz;
memmove(pv, pv + 1, sizeof (*pv) * ((ep - pv) - 1));
hdb->fbpnum--;
- //HDBUNLOCKDB(hdb);
return true;
}
pv++;
}
- //HDBUNLOCKDB(hdb);
return false;
}
uint64_t off = rec->off + rec->rsiz;
static void tchdbfbptrim(TCHDB *hdb, uint64_t base, uint64_t next, uint64_t off, uint32_t rsiz) {
assert(hdb && base > 0 && next > 0);
if (hdb->fpow < 1) return;
-// if (!HDBLOCKDB(hdb)) return;
if (hdb->fbpnum < 1) {
if (off > 0) {
HDBFB *fbpool = hdb->fbpool;
fbpool->rsiz = rsiz;
hdb->fbpnum = 1;
}
-// HDBUNLOCKDB(hdb);
return;
}
HDBFB *wp = hdb->fbpool;
off = 0;
}
hdb->fbpnum = wp - (HDBFB *) hdb->fbpool;
-// HDBUNLOCKDB(hdb);
}
/* Write a free block into the file.