From bf9d722bec7d0e6094242b405d6a66720b934fc6 Mon Sep 17 00:00:00 2001 From: Hallvard Furuseth Date: Sat, 10 Sep 2011 10:11:56 +0200 Subject: [PATCH] mdb type cleanup: Consistent reader count types. Use unsigned int for reader counts/max limits, that's the smallest change. Don't need uint32_t when mdb_env_set_maxreaders() takes less. Change prototypes of mdb_env_set_maxreaders,mdb_env_get_maxreaders(). Check the mdb_env_set_maxreaders() argument. --- libraries/libmdb/mdb.c | 8 ++++---- libraries/libmdb/mdb.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/libmdb/mdb.c b/libraries/libmdb/mdb.c index b73541bd39..1a539ba1cb 100644 --- a/libraries/libmdb/mdb.c +++ b/libraries/libmdb/mdb.c @@ -436,7 +436,7 @@ typedef struct MDB_txbody { * This always records the maximum count, it is not decremented * when readers release their slots. */ - uint32_t mtb_numreaders; + unsigned mtb_numreaders; /** The ID of the most recent meta page in the database. * This is recorded here only for convenience; the value can always * be determined by reading the main database meta pages. @@ -1819,16 +1819,16 @@ mdb_env_set_maxdbs(MDB_env *env, int dbs) } int -mdb_env_set_maxreaders(MDB_env *env, int readers) +mdb_env_set_maxreaders(MDB_env *env, unsigned int readers) { - if (env->me_map) + if (env->me_map || readers < 1) return EINVAL; env->me_maxreaders = readers; return MDB_SUCCESS; } int -mdb_env_get_maxreaders(MDB_env *env, int *readers) +mdb_env_get_maxreaders(MDB_env *env, unsigned int *readers) { if (!env || !readers) return EINVAL; diff --git a/libraries/libmdb/mdb.h b/libraries/libmdb/mdb.h index c0d4edcf4a..f718c35ac3 100644 --- a/libraries/libmdb/mdb.h +++ b/libraries/libmdb/mdb.h @@ -414,7 +414,7 @@ int mdb_env_set_mapsize(MDB_env *env, size_t size); *
  • EINVAL - an invalid parameter was specified, or the environment is already open. * */ -int mdb_env_set_maxreaders(MDB_env *env, int readers); +int mdb_env_set_maxreaders(MDB_env *env, unsigned int readers); /** Get the maximum number of threads for the environment. * @param[in] env An environment handle returned by #mdb_env_create() @@ -425,7 +425,7 @@ int mdb_env_set_maxreaders(MDB_env *env, int readers); *
  • EINVAL - an invalid parameter was specified. * */ -int mdb_env_get_maxreaders(MDB_env *env, int *readers); +int mdb_env_get_maxreaders(MDB_env *env, unsigned int *readers); /** Set the maximum number of databases for the environment. * This function is only needed if multiple databases will be used in the -- 2.39.5