Commit Graph

11 Commits

Author SHA1 Message Date
Martchus 156e01f15d Fix typos in README 2022-01-18 22:38:12 +01:00
Martchus 826637167c Update README for Reflective RapidJSON 2022-01-18 22:35:23 +01:00
Martchus 462e5e4b51 Fix example for iterating range
One must use `equal_range` here, otherwise the iteration will not stop
after the last matching key.
2022-01-18 21:53:51 +01:00
Jonas Schäfer 3c57c6a113 Hide MDB*Transaction behind a unique_ptr front
This is to prevent the issue with Object Slicing. With the previous
solution (where MDB*Transaction are normal objects), consider the
following code:

    MDBRWTransaction txn = env.getRWTransaction();

    //! Invalid: We explicitly break this move because it would be
    //! unsafe:
    // MDBROTransaction ro_txn(std::move(txn));

    //! Valid, RW inherits from RO now, so we can bind an RO
    //! reference to an RW transaction.
    MDBROTransaction &ro_txn = txn;

    //! Dangerous!!
    MDBROTransaction ro_txn2(std::move(ro_txn));

The last move there breaks the semantics of the RW transaction which
is bound to the reference ro_txn. It looses its RW cursors, which
remain partly inside the txn instance. All kinds of weird and bad
things can happen here. For instance, the ro_txn2 would go out of
scope before the txn, calling the destructor MDBROTransaction
destructor (which defaults to commit instead of abort!) and only
freeing parts of the cursors. Only then the MDBRWTransaction
destructor is called, which will free the cursors which belong to
the RW transaction which has already been committed.

The only safe way to prevent Object Slicing in this scenario I
could come up with is to disallow moves of the objects altogether
and instead use unique_ptr as front for them. This also removes
an additional dynamic allocation per RW transaction (for the
cursor vector), since the address of that vector is now constant
over the lifetime of the transaction without indirection.
2019-11-11 21:23:20 +01:00
bert hubert f11d89dd4a more docs + cleanups 2018-12-15 01:54:29 +01:00
bert hubert 3dd2f703db namespace cleanup, reennable support for c++2011 2018-12-10 22:08:49 +01:00
bert hubert 34f8c2188c better docs 2018-12-10 17:42:25 +01:00
bert hubert ac9da997a0 fix mixup with mode & flags parameters, implement transaction restart in case of resize 2018-12-10 10:27:07 +01:00
bert hubert 5cbaf71227 docs 2018-12-08 20:57:39 +01:00
bert hubert c40719f671 some docs, basic example 2018-12-08 14:08:26 +01:00
bert hubert f1100abed4
Initial commit 2018-12-05 15:46:05 +01:00