Shed the pointless per-dbi memory allocators
authorPanu Matilainen <pmatilai@redhat.com>
Tue, 30 Mar 2010 22:12:15 +0000 (01:12 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Tue, 30 Mar 2010 22:12:15 +0000 (01:12 +0300)
- 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
lib/rpmdb.c
lib/rpmdb_internal.h

index 0b058dd..7c40420 100644 (file)
@@ -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);
            }
 
index 5ea8cfe..cc2d33c 100644 (file)
@@ -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);
index 7991b26..997f0d6 100644 (file)
@@ -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;