summaryrefslogtreecommitdiff
path: root/ext/dba/dba_lmdb.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/dba/dba_lmdb.c')
-rw-r--r--ext/dba/dba_lmdb.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/ext/dba/dba_lmdb.c b/ext/dba/dba_lmdb.c
index 506ae00827..b3f6442e0c 100644
--- a/ext/dba/dba_lmdb.c
+++ b/ext/dba/dba_lmdb.c
@@ -43,10 +43,18 @@ DBA_OPEN_FUNC(lmdb)
MDB_env *env;
MDB_txn *txn;
int rc, mode = 0644, flags = MDB_NOSUBDIR;
+ zend_long mapsize = 0;
if(info->argc > 0) {
mode = zval_get_long(&info->argv[0]);
+ if (info->argc > 1) {
+ mapsize = zval_get_long(&info->argv[1]);
+ if (mapsize < 0) {
+ *error = "mapsize must be greater than or equal to zero";
+ return FAILURE;
+ }
+ }
/* TODO implement handling of the additional flags. */
}
@@ -56,6 +64,14 @@ DBA_OPEN_FUNC(lmdb)
return FAILURE;
}
+ if (mapsize > 0) {
+ rc = mdb_env_set_mapsize(env, (size_t) mapsize);
+ if (rc) {
+ *error = mdb_strerror(rc);
+ return FAILURE;
+ }
+ }
+
rc = mdb_env_open(env, info->path, flags, mode);
if (rc) {
*error = mdb_strerror(rc);