summaryrefslogtreecommitdiffstatshomepage
path: root/examples/natmod/btree
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2020-04-20 23:04:40 +1000
committerDamien George <damien.p.george@gmail.com>2020-05-02 16:08:04 +1000
commit73c58150f53d9d828c4fc8fb455cca6831eb8ddd (patch)
tree04e2c37efd92a1058291613e8c8108edfec36a41 /examples/natmod/btree
parent391927c12634e3b80882499de5e92740c8472452 (diff)
downloadmicropython-73c58150f53d9d828c4fc8fb455cca6831eb8ddd.tar.gz
micropython-73c58150f53d9d828c4fc8fb455cca6831eb8ddd.zip
extmod/modbtree: Retain reference to underlying stream so it's not GC'd.
For ports that have a system malloc which is not garbage collected (eg unix, esp32), the stream object for the DB must be retained separately to prevent it from being reclaimed by the MicroPython GC (because the berkeley-db library uses malloc to allocate the DB structure which stores the only reference to the stream). Although in some cases the user code will explicitly retain a reference to the underlying stream because it needs to call close() on it, this is not always the case, eg in cases where the DB is intended to live forever. Fixes issue #5940.
Diffstat (limited to 'examples/natmod/btree')
-rw-r--r--examples/natmod/btree/btree_c.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/examples/natmod/btree/btree_c.c b/examples/natmod/btree/btree_c.c
index f3e4790ed2..5e8a34ac40 100644
--- a/examples/natmod/btree/btree_c.c
+++ b/examples/natmod/btree/btree_c.c
@@ -115,7 +115,7 @@ STATIC mp_obj_t btree_open(size_t n_args, const mp_obj_t *args) {
mp_raise_OSError(native_errno);
}
- return MP_OBJ_FROM_PTR(btree_new(db));
+ return MP_OBJ_FROM_PTR(btree_new(db, args[0]));
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(btree_open_obj, 5, 5, btree_open);