cdb_fetch()/cdb_next_item() return immutable data
authorArt Cancro <ajc@citadel.org>
Sun, 20 Aug 2023 02:42:31 +0000 (17:42 -0900)
committerArt Cancro <ajc@citadel.org>
Sun, 20 Aug 2023 02:42:31 +0000 (17:42 -0900)
commit3c40b8829417e15d5b62226a43778b1dbec8a16c
tree53fcb251f612cd46907d08aed2299838b00edb23
parent4432ed8e18a3c8c4326a9b6692a4c5f641671171
cdb_fetch()/cdb_next_item() return immutable data

************************************************************************

Before now, the Berkeley DB back end was supplied the DB_DBT_MALLOC flag
and it became the caller's responsibility to handle any memory allocated
and returned by cdb_fetch() and cdb_next_item().  These heuristics are
not expected to be compatible with new back ends currently in planning.

cdb_fetch() and cdb_next_item() now return data that is to be considered
immutable (don't write to it or you'll segfault).  The caller must still
call cdb_free() to free the `struct cdbdata` itself, but the pointers
inside it point to buffers that the back end will reuse.

After a call to cdb_fetch() or cdb_next_item(), the buffers are
guaranteed to be readable until the next call to one of those functions
on the same table.
citadel/server/backends/berkeley_db/berkeley_db.c