]> git.sur5r.net Git - openldap/blobdiff - libraries/libmdb/mdb.c
Fix MDB_txninfo.mt2 padding on Windows/Apple
[openldap] / libraries / libmdb / mdb.c
index 6abadd2fbe17d1146430552d2c327e18af13c0ab..b714119c1069933f1e8b1254982cddca1e44e23f 100644 (file)
 
 #if defined(_WIN32) || defined(__APPLE__)
 #define MNAME_LEN      32
+#else
+#define MNAME_LEN      (sizeof(pthread_mutex_t))
 #endif
 
 /** @} */
@@ -543,7 +545,7 @@ typedef struct MDB_txninfo {
                pthread_mutex_t mt2_wmutex;
 #define mti_wmutex     mt2.mt2_wmutex
 #endif
-               char pad[(sizeof(pthread_mutex_t)+CACHELINE-1) & ~(CACHELINE-1)];
+               char pad[(MNAME_LEN+CACHELINE-1) & ~(CACHELINE-1)];
        } mt2;
        MDB_reader      mti_readers[1];
 } MDB_txninfo;
@@ -1126,13 +1128,11 @@ static MDB_page *
 mdb_page_malloc(MDB_cursor *mc) {
        MDB_page *ret;
        size_t sz = mc->mc_txn->mt_env->me_psize;
-       if (mc->mc_txn->mt_env->me_dpages) {
-               ret = mc->mc_txn->mt_env->me_dpages;
+       if ((ret = mc->mc_txn->mt_env->me_dpages) != NULL) {
                VGMEMP_ALLOC(mc->mc_txn->mt_env, ret, sz);
                VGMEMP_DEFINED(ret, sizeof(ret->mp_next));
                mc->mc_txn->mt_env->me_dpages = ret->mp_next;
-       } else {
-               ret = malloc(sz);
+       } else if ((ret = malloc(sz)) != NULL) {
                VGMEMP_ALLOC(mc->mc_txn->mt_env, ret, sz);
        }
        return ret;