mirror of
https://github.com/isar/libmdbx.git
synced 2024-10-30 11:29:19 +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
13
src/mdbx.c
13
src/mdbx.c
@ -12793,9 +12793,20 @@ static int __cold mdbx_env_walk(mdbx_walk_ctx_t *ctx, const char *dbi,
|
||||
|
||||
MDBX_db db;
|
||||
memcpy(&db, NODEDATA(node), sizeof(db));
|
||||
char *name = memcpy(alloca(namelen + 1), NODEKEY(node), namelen);
|
||||
|
||||
char namebuf_onstask[142];
|
||||
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;
|
||||
|
||||
case F_SUBDATA | F_DUPDATA /* dupsorted sub-tree */: {
|
||||
|
Loading…
Reference in New Issue
Block a user