### Berkeley DB Reference Guide: Upgrading Berkeley DB Applications |

# Release 3.3: DB->set_malloc, DB->set_realloc

There are two new interfaces in the Berkeley DB 3.3 release: DB_ENV->set_alloc and DB->set_alloc. These functions allow applications to specify a set of allocation functions for the Berkeley DB library to use when allocating memory to be owned by the application and when freeing memory that was originally allocated by the application.

The new interfaces affect or replace the following historic interfaces:

DB->set_malloc
  The DB->set_malloc interface has been replaced in its entirety. Applications using this interface should replace the call with a call to DB->set_alloc.

DB->set_realloc
  The DB->set_realloc interface has been replaced in its entirety. Applications using this interface should replace the call with a call to DB->set_alloc.

DB->stat
  The historic db_malloc argument to the DB->stat function has been replaced. Applications using this interface should do as follows: if the argument is NULL, it should simply be removed. If non-NULL, it should be replaced with a call to DB->set_alloc.

lock_stat
  The historic db_malloc argument to the lock_stat interface has been replaced. Applications using this interface should do as follows: if the argument is NULL, it should simply be removed. If non-NULL, it should be replaced with a call to DB_ENV->set_alloc.

log_archive
  The historic db_malloc argument to the log_archive interface has been replaced. Applications using this interface should do as follows: if the argument is NULL, it should simply be removed. If non-NULL, it should be replaced with a call to DB_ENV->set_alloc.

log_stat
  The historic db_malloc argument to the log_stat interface has been replaced. Applications using this interface should do as follows: if the argument is NULL, it should simply be removed. If non-NULL, it should be replaced with a call to DB_ENV->set_alloc.

memp_stat
  The historic db_malloc argument to the memp_stat function has been replaced. Applications using this interface should do as follows: if the argument is NULL, it should simply be removed. If non-NULL, it should be replaced with a call to DB_ENV->set_alloc.

txn_stat
  The historic db_malloc argument to the txn_stat function has been replaced. Applications using this interface should do as follows: if the argument is NULL, it should simply be removed. If non-NULL, it should be replaced with a call to DB_ENV->set_alloc.

One potential incompatibility for historic applications is that the allocation functions for a database environment must now be set before the environment is opened. Historically, Berkeley DB applications could open the environment first, and subsequently call the DB->set_malloc and DB->set_realloc interfaces; that use is no longer supported.

Copyright Sleepycat Software