mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-04 18:14:12 +08:00
mdbx: avoid on-stack allocation/chkstk inside mdbx_env_walk().
5 of 17 for https://github.com/leo-yuriev/libmdbx/issues/43 Change-Id: Iadb833ff38dbd0922eda69238b365f5906b9109f
This commit is contained in:
parent
180c605cac
commit
aa64597e8b
17
src/mdbx.c
17
src/mdbx.c
@ -12793,9 +12793,20 @@ static int __cold mdbx_env_walk(mdbx_walk_ctx_t *ctx, const char *dbi,
|
|||||||
|
|
||||||
MDBX_db db;
|
MDBX_db db;
|
||||||
memcpy(&db, NODEDATA(node), sizeof(db));
|
memcpy(&db, NODEDATA(node), sizeof(db));
|
||||||
char *name = memcpy(alloca(namelen + 1), NODEKEY(node), namelen);
|
|
||||||
name[namelen] = 0;
|
char namebuf_onstask[142];
|
||||||
rc = mdbx_env_walk(ctx, name, db.md_root, deep + 1);
|
char *const name = (namelen < sizeof(namebuf_onstask))
|
||||||
|
? namebuf_onstask
|
||||||
|
: mdbx_malloc(namelen + 1);
|
||||||
|
if (name) {
|
||||||
|
memcpy(name, NODEKEY(node), namelen);
|
||||||
|
name[namelen] = 0;
|
||||||
|
rc = mdbx_env_walk(ctx, name, db.md_root, deep + 1);
|
||||||
|
if (name != namebuf_onstask)
|
||||||
|
mdbx_free(name);
|
||||||
|
} else {
|
||||||
|
rc = MDBX_ENOMEM;
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case F_SUBDATA | F_DUPDATA /* dupsorted sub-tree */: {
|
case F_SUBDATA | F_DUPDATA /* dupsorted sub-tree */: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user