提交 4e0d69c6 编写于 作者: D dapan1121

fix: memory leak in tdb

上级 e5023259
...@@ -2188,6 +2188,9 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) { ...@@ -2188,6 +2188,9 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) {
} else { } else {
lidx = lidx + 1; lidx = lidx + 1;
} }
if (TDB_CELLDECODER_FREE_KEY(&pBtc->coder)) {
tdbFree((void*)pTKey);
}
// compare last cell // compare last cell
if (lidx <= ridx) { if (lidx <= ridx) {
...@@ -2199,6 +2202,9 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) { ...@@ -2199,6 +2202,9 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) {
} else { } else {
ridx = ridx - 1; ridx = ridx - 1;
} }
if (TDB_CELLDECODER_FREE_KEY(&pBtc->coder)) {
tdbFree((void*)pTKey);
}
} }
// binary search // binary search
...@@ -2209,6 +2215,9 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) { ...@@ -2209,6 +2215,9 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) {
pBtc->idx = (lidx + ridx) >> 1; pBtc->idx = (lidx + ridx) >> 1;
tdbBtcGet(pBtc, &pTKey, &tkLen, NULL, NULL); tdbBtcGet(pBtc, &pTKey, &tkLen, NULL, NULL);
c = pBt->kcmpr(pKey, kLen, pTKey, tkLen); c = pBt->kcmpr(pKey, kLen, pTKey, tkLen);
if (TDB_CELLDECODER_FREE_KEY(&pBtc->coder)) {
tdbFree((void*)pTKey);
}
if (c < 0) { if (c < 0) {
// pKey < cd.pKey // pKey < cd.pKey
ridx = pBtc->idx - 1; ridx = pBtc->idx - 1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册