Standards / Extensions | C or C++ | Dependencies |
---|---|---|
XPG4.2 |
both |
#define _XOPEN_SOURCE_EXTENDED 1
#include <ndbm.h>
int dbm_delete(DBM *db, datum key);
The dbm_delete() function deletes a record and its key from the database. The db argument specifies the database handle returned by a previous call to dbm_open(). The key argument identifies the record the program is deleting. The key datum must contain a dptr pointer to the key, and the key length in dsize.
After calling dbm_delete(), during a pass through the keys by dbm_firstkey() and dbm_nextkey(), the application positioning must be reset by calling dbm_firstkey(). If not, unpredictable results may occur including retrieval of the same key multiple times, or not at all.
File space is not physically reclaimed by a dbm_delete() operation. That is, the file size is not reduced. However, the space is available for reuse, subject to hashing.
Special behavior for z/OS® UNIX Services: In a multithreaded environment, changes made to the database by a dbm_delete() operation affect all threads using the database handle. Thus, all other threads must also reset their positioning by using the dbm_firstkey() function before using dbm_nextkey(). A previously executed dbm_fetch() operation by another thread for the same key still has correct buffer pointers to the previous data. The dbm_delete() operation does not affect this. All other operations on other threads, such as dbm_fetch() to this (now) deleted key will fail.
If successful, dbm_delete() returns 0.
If unsuccessful, dbm_delete() returns -1 and sets the error value in errno. Also, the database error indicator may be set.