return NULL;
}
-#if DB_VERSION_MINOR >= 3
+#if DB_VERSION_MAJOR > 3 || DB_VERSION_MINOR >= 3
+ /* This interface appeared in 3.3 */
env->set_alloc( env, ldbm_malloc, NULL, NULL );
#endif
ldbm_close( LDBM ldbm )
{
LDBM_WLOCK;
-#if DB_VERSION_MAJOR >= 3
+#if DB_VERSION_MAJOR >= 2
ldbm->close( ldbm, 0 );
-#elif DB_VERSION_MAJOR >= 2
- (*ldbm->close)( ldbm, 0 );
#else
- (*ldbm->close)( ldbm );
+ ldbm->close( ldbm );
#endif
LDBM_WUNLOCK;
}
LDBM_RLOCK;
-#if DB_VERSION_MAJOR >= 3
+#if DB_VERSION_MAJOR >= 2
ldbm_datum_init( data );
data.flags = DB_DBT_MALLOC;
data.dptr = NULL;
data.dsize = 0;
}
-
-#elif DB_VERSION_MAJOR >= 2
- ldbm_datum_init( data );
-
- data.flags = DB_DBT_MALLOC;
-
- if ( (rc = (*ldbm->get)( ldbm, NULL, &key, &data, 0 )) != 0 ) {
- ldbm_datum_free( ldbm, data );
- data.dptr = NULL;
- data.dsize = 0;
- }
#else
-
- if ( (rc = (*ldbm->get)( ldbm, &key, &data, 0 )) == 0 ) {
+ if ( (rc = ldbm->get( ldbm, &key, &data, 0 )) == 0 ) {
/* Berkeley DB 1.85 don't malloc the data for us */
/* duplicate it for to ensure reentrancy */
data = ldbm_datum_dup( ldbm, data );
LDBM_WLOCK;
-#if DB_VERSION_MAJOR >= 3
+#if DB_VERSION_MAJOR >= 2
rc = ldbm->put( ldbm, NULL, &key, &data, flags & ~LDBM_SYNC );
rc = (-1) * rc;
-
-#elif DB_VERSION_MAJOR >= 2
- rc = (*ldbm->put)( ldbm, NULL, &key, &data, flags & ~LDBM_SYNC );
- rc = (-1) * rc;
#else
- rc = (*ldbm->put)( ldbm, &key, &data, flags & ~LDBM_SYNC );
+ rc = ldbm->put( ldbm, &key, &data, flags & ~LDBM_SYNC );
#endif
if ( flags & LDBM_SYNC )
- (*ldbm->sync)( ldbm, 0 );
+ ldbm->sync( ldbm, 0 );
LDBM_WUNLOCK;
LDBM_WLOCK;
-#if DB_VERSION_MAJOR >= 3
+#if DB_VERSION_MAJOR >= 2
rc = ldbm->del( ldbm, NULL, &key, 0 );
rc = (-1) * rc;
-#elif DB_VERSION_MAJOR >= 2
- rc = (*ldbm->del)( ldbm, NULL, &key, 0 );
- rc = (-1) * rc;
#else
- rc = (*ldbm->del)( ldbm, &key, 0 );
+ rc = ldbm->del( ldbm, &key, 0 );
#endif
- (*ldbm->sync)( ldbm, 0 );
+ ldbm->sync( ldbm, 0 );
LDBM_WUNLOCK;
LDBM_RLOCK;
/* acquire a cursor for the DB */
-# if DB_VERSION_MAJOR >= 3
+# if DB_VERSION_MAJOR >= 3 || (DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR > 5)
rc = ldbm->cursor( ldbm, NULL, &dbci, 0 );
-# elif defined( DB_VERSION_MAJOR ) && defined( DB_VERSION_MINOR ) && \
- (DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR < 6)
- rc = (*ldbm->cursor)( ldbm, NULL, &dbci );
# else
- rc = (*ldbm->cursor)( ldbm, NULL, &dbci, 0 );
+ rc = ldbm->cursor( ldbm, NULL, &dbci );
# endif
if( rc ) {
key.dptr = NULL;
} else {
*dbch = dbci;
- if ( (*dbci->c_get)( dbci, &key, &data, DB_NEXT ) == 0 ) {
+ if ( dbci->c_get( dbci, &key, &data, DB_NEXT ) == 0 ) {
ldbm_datum_free( ldbm, data );
} else {
key.dptr = NULL;
#else
LDBM_RLOCK;
- rc = (*ldbm->seq)( ldbm, &key, &data, R_FIRST );
+ rc = ldbm->seq( ldbm, &key, &data, R_FIRST );
if ( rc == 0 ) {
key = ldbm_datum_dup( ldbm, key );
ldbm_datum_free( ldbm, key );
key.flags = data.flags = DB_DBT_MALLOC;
- rc = (*dbcp->c_get)( dbcp, &key, &data, DB_NEXT );
+ rc = dbcp->c_get( dbcp, &key, &data, DB_NEXT );
if ( rc == 0 ) {
ldbm_datum_free( ldbm, data );
} else
#else
- rc = (*ldbm->seq)( ldbm, &key, &data, R_NEXT );
+ rc = ldbm->seq( ldbm, &key, &data, R_NEXT );
if ( rc == 0 ) {
key = ldbm_datum_dup( ldbm, key );