From: Kurt Zeilenga Date: Fri, 11 Feb 2000 02:05:14 +0000 (+0000) Subject: ITS#450: teach LDBM/GDBM about cursors X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~3192 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=6968ede5340e6e29aa61b1418b0a925237932797;p=openldap ITS#450: teach LDBM/GDBM about cursors --- diff --git a/include/ldbm.h b/include/ldbm.h index 145c882968..e7f0b10f98 100644 --- a/include/ldbm.h +++ b/include/ldbm.h @@ -66,7 +66,7 @@ typedef DBC LDBMCursor; # endif #else -typedef int LDBMCursor; +typedef void LDBMCursor; # define LDBM_READER O_RDONLY # define LDBM_WRITER O_RDWR # define LDBM_WRCREAT (O_RDWR|O_CREAT) @@ -107,7 +107,7 @@ LDAP_END_DECL LDAP_BEGIN_DECL typedef datum Datum; -typedef int LDBMCursor; +typedef Datum LDBMCursor; typedef GDBM_FILE LDBM; extern gdbm_error gdbm_errno; diff --git a/libraries/libldbm/ldbm.c b/libraries/libldbm/ldbm.c index 59305bb582..33592e7be6 100644 --- a/libraries/libldbm/ldbm.c +++ b/libraries/libldbm/ldbm.c @@ -529,6 +529,11 @@ ldbm_firstkey( LDBM ldbm, LDBMCursor **dbcp ) d = gdbm_firstkey( ldbm ); LDBM_UNLOCK; + if ( d.dptr != NULL ) { + *dbcp = (Datum *) malloc( sizeof( Datum ) ); + **dbcp = ldbm_datum_dup( ldbm, d ); + } + return d; } @@ -538,9 +543,17 @@ ldbm_nextkey( LDBM ldbm, Datum key, LDBMCursor *dbcp ) Datum d; LDBM_LOCK; - d = gdbm_nextkey( ldbm, key ); + d = gdbm_nextkey( ldbm, *dbcp ); LDBM_UNLOCK; + ldbm_datum_free( ldbm, *dbcp ); + + if ( d.dptr != NULL ) { + *dbcp = ldbm_datum_dup( ldbm, d ); + } else { + free( dbcp ); + } + return d; }