mdbx package code
Copyright (c) 2026 Pedro Baltazar
License: MIT

Covers everything outside src/vendor/: the R sources under R/, the binding
layer src/r_mdbx.cpp, src/r_mdbx.h, src/r_flags.cpp, src/r_mdbx_hooks.cpp and
src/r_mdbx_hooks.h, the cpp11-generated src/cpp11.cpp and R/cpp11.R, the build
glue src/Makevars and src/Makevars.win, and the contents of man/ and tests/.
The same applies to the maintainer scripts under tools/ in the source
repository, which are not part of the distributed package.

Vendored third-party code
=========================

Component: libmdbx (aka MDBX)
Location: src/vendor/libmdbx
Upstream: https://libmdbx.dqdkfa.ru
Copyright (c) 2015-2026 Leonid Yuriev <leo@yuriev.ru>
License: Apache-2.0

The vendored files are mdbx.c, mdbx.h and mdbx-internals.h -- the three files
that constitute the official libmdbx amalgamation -- together with the upstream
LICENSE, NOTICE and COPYRIGHT, which are retained verbatim in
src/vendor/libmdbx and apply to the files there. libmdbx's command-line tools,
C++ API, test suite and build system are not vendored.

The sources were taken from release tag v0.14.3 (tag object
cf3e13938bf974260872e629713f6ecf30e62030, commit
f7a3a9323cacacfa9dc6137ae7a7252a67744ff0) via upstream's GitHub mirror at
https://github.com/erthink/libmdbx. Per-file SHA-256 digests of the pristine
sources are recorded in .agents/vendoring.md in the package's source
repository.

Local modifications to the vendored sources, which constitute the notice
required by section 4(b) of the Apache License, are confined to
src/vendor/libmdbx/mdbx.c, src/vendor/libmdbx/mdbx.h and
src/vendor/libmdbx/mdbx-internals.h. They route libmdbx's panic path through a
package-owned guard that marks the owning handle unusable and raises an R
condition instead of calling the platform assert handler or abort(); send log
output through R's console instead of stderr; read NT_TIB::Self directly rather
than through __readgsqword(), which avoids a false-positive -Warray-bounds from
Rtools' MinGW headers; remove nine upstream diagnostic-suppression pragmas
(#pragma GCC/clang diagnostic ignored ...), which are unnecessary under R's
compilation flags and trip CRAN's pragma check; and restrict the compatibility
definitions of bool, true, false and nullptr to compilers older than C23, which
promoted all four to keywords; and declare three trailing arrays that are
deliberately indexed past their declared length (the dirty-page list, the
defragmentation map list and the write-ring gather list) as C99 flexible array
members, or index them through a pointer, so that bounds-checking sanitizers do
not report them. Allocation sizes are unchanged. They also let the memory
map be retried at a smaller size when mmap() refuses a large reservation with
EINVAL, which upstream does only in builds instrumented for Valgrind or
AddressSanitizer; and copy
only the populated part of a free-list record into the database page,
zero-filling the rest of it, instead of copying uninitialised memory that is
then written to disk; and add one function that reports where an
environment's page-number lists start, so that the package can keep
environments it deliberately never closes visibly reachable to memory
checkers. Together these ensure no compiled code writes to
stderr or terminates the R process. Each change is also recorded as a patch in
tools/patches/ in the package's source repository. LICENSE, NOTICE and COPYRIGHT
are unmodified.

Third-party code within libmdbx
===============================

libmdbx was derived from LMDB in 2015 and subsequently rewritten. The copyright
notices and licences of that ancestry are reproduced in full in
src/vendor/libmdbx/COPYRIGHT, and are in summary:

Component: LMDB
Copyright (c) 2011-2015 Howard Chu, Symas Corp. All rights reserved.
License: OpenLDAP Public License

Component: btree.c, from which LMDB derived code
Copyright (c) 2009, 2010 Martin Hedenfalk <martin@bzero.se>
License: ISC-style permissive licence
