]> git.sur5r.net Git - openldap/commitdiff
Wrap stat() st_blksize use behind HAVE_ST_BLKSIZE
authorKurt Zeilenga <kurt@openldap.org>
Sat, 17 Apr 1999 03:28:20 +0000 (03:28 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Sat, 17 Apr 1999 03:28:20 +0000 (03:28 +0000)
libraries/libldbm/ldbm.c

index 4a9fbc59f7d65d61f4125342ab42e1259ff10ea8..678a7e5b3e9480c14d75e5ce6053ea7df129fbb7 100644 (file)
@@ -26,6 +26,7 @@ ldbm_datum_free( LDBM ldbm, Datum data )
        if ( data.dptr ) {
                free( data.dptr );
                memset( &data, 0, sizeof( Datum ));
+               data.dptr = NULL;
        }
 }
 
@@ -411,7 +412,9 @@ ldbm_errno( LDBM ldbm )
 
 #elif defined( HAVE_GDBM )
 
+#ifdef HAVE_ST_BLKSIZE
 #include <sys/stat.h>
+#endif
 
 /*****************************************************************
  *                                                               *
@@ -423,7 +426,6 @@ LDBM
 ldbm_open( char *name, int rw, int mode, int dbcachesize )
 {
        LDBM            db;
-       struct stat     st;
 
        LDBM_LOCK;
 
@@ -431,10 +433,17 @@ ldbm_open( char *name, int rw, int mode, int dbcachesize )
                LDBM_UNLOCK;
                return( NULL );
        }
+
+#ifdef HAVE_ST_BLKSIZE
        if ( dbcachesize > 0 && stat( name, &st ) == 0 ) {
+               struct stat     st;
                dbcachesize = (dbcachesize / st.st_blksize);
                gdbm_setopt( db, GDBM_CACHESIZE, &dbcachesize, sizeof(int) );
        }
+#else
+       dbcachesize = (dbcachesize / 4096);
+       gdbm_setopt( db, GDBM_CACHESIZE, &dbcachesize, sizeof(int) );
+#endif
 
        LDBM_UNLOCK;