From fbc11b67656e93bccef495a09b1a59805c1dde3f Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Wed, 31 Mar 2010 01:12:15 +0300 Subject: [PATCH] Shed the pointless per-dbi memory allocators - we want to use our own allocators for exit-on-enomem behavior but having per-index allocator configuration makes no sense whatsoever --- lib/backend/db3.c | 5 ++--- lib/rpmdb.c | 3 --- lib/rpmdb_internal.h | 6 +----- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/lib/backend/db3.c b/lib/backend/db3.c index 0b058dd..7c40420 100644 --- a/lib/backend/db3.c +++ b/lib/backend/db3.c @@ -127,7 +127,7 @@ static int db_init(dbiIndex dbi, const char * dbhome, DB_ENV ** dbenvp) if (dbenv == NULL || rc) goto errxit; - dbenv->set_alloc(dbenv,rpmdb->db_malloc, rpmdb->db_realloc, rpmdb->db_free); + dbenv->set_alloc(dbenv, rmalloc, rrealloc, NULL); dbenv->set_errcall(dbenv, (void *) rpmdb->db_errcall); dbenv->set_errfile(dbenv, rpmdb->db_errfile); dbenv->set_errpfx(dbenv, rpmdb->db_errpfx); @@ -660,8 +660,7 @@ int dbiOpenDB(rpmdb rpmdb, rpmTag rpmtag, dbiIndex * dbip) rc = cvtdberr(dbi, "db_create", rc, _debug); if (rc == 0 && db != NULL) { if (rc == 0 && !dbi->dbi_use_dbenv) { - rc = db->set_alloc(db, - rpmdb->db_malloc, rpmdb->db_realloc, rpmdb->db_free); + rc = db->set_alloc(db, rmalloc, rrealloc, NULL); rc = cvtdberr(dbi, "db->set_alloc", rc, _debug); } diff --git a/lib/rpmdb.c b/lib/rpmdb.c index 5ea8cfe..cc2d33c 100644 --- a/lib/rpmdb.c +++ b/lib/rpmdb.c @@ -749,9 +749,6 @@ rpmdb newRpmdb(const char * root, db->db_errpfx = rpmExpand( (epfx && *epfx ? epfx : _DB_ERRPFX), NULL); /* XXX remove environment after chrooted operations, for now... */ db->db_remove_env = (!rstreq(db->db_root, "/") ? 1 : 0); - db->db_malloc = rmalloc; - db->db_realloc = rrealloc; - db->db_free = NULL; /* XXX rfree() prototype differs from free() */ db->_dbi = xcalloc(dbiTagsMax, sizeof(*db->_dbi)); db->nrefs = 0; return rpmdbLink(db); diff --git a/lib/rpmdb_internal.h b/lib/rpmdb_internal.h index 7991b26..997f0d6 100644 --- a/lib/rpmdb_internal.h +++ b/lib/rpmdb_internal.h @@ -99,7 +99,6 @@ unsigned char * dbi_lk_conflicts; #endif /* dbinfo parameters */ int dbi_pagesize; /*!< (fs blksize) */ - void * (*dbi_malloc) (size_t nbytes); /* hash access parameters */ unsigned int dbi_h_ffactor; /*!< */ unsigned int (*dbi_h_hash_fcn) (DB *, const void *bytes, @@ -148,15 +147,12 @@ struct rpmdb_s { int db_mkdirDone; /*!< Has db_home been created? */ void (*db_errcall) (const char *db_errpfx, char *buffer); FILE * db_errfile; - void * (*db_malloc) (size_t nbytes); - void * (*db_realloc) (void * ptr, - size_t nbytes); - void (*db_free) (void * ptr); unsigned char * db_bits; /*!< package instance bit mask. */ int db_nbits; /*!< no. of bits in mask. */ rpmdb db_next; int db_opens; void * db_dbenv; /*!< Berkeley DB_ENV handle. */ + int db_ndbi; /*!< No. of tag indices. */ dbiIndex * _dbi; /*!< Tag indices. */ struct rpmop_s db_getops; -- 2.7.4