Have BDB use our allocation routines now that we can
authorPanu Matilainen <pmatilai@redhat.com>
Thu, 17 Sep 2009 09:25:31 +0000 (12:25 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Thu, 17 Sep 2009 09:32:04 +0000 (12:32 +0300)
- rfree() prototype doesn't match free() but it doesn't matter in this
  case as it's just a convencience wrapper with no extra functionality
  and setting NULL is ok according to BDB docs
- db->set_alloc() can't be used if environment is used, fix the condition

lib/backend/db3.c
lib/rpmdb.c

index 03f9588..4dba73b 100644 (file)
@@ -135,10 +135,10 @@ static int db_init(dbiIndex dbi, const char * dbhome, DB_ENV ** dbenvp)
   { int xx;
 
  /* 4.1: dbenv->set_app_dispatch(???) */
- /* 4.1: dbenv->set_alloc(???) */
  /* 4.1: dbenv->set_data_dir(???) */
  /* 4.1: dbenv->set_encrypt(???) */
 
+    dbenv->set_alloc(dbenv,rpmdb->db_malloc, rpmdb->db_realloc, rpmdb->db_free);
     dbenv->set_errcall(dbenv, (void *) rpmdb->db_errcall);
     dbenv->set_errfile(dbenv, rpmdb->db_errfile);
     dbenv->set_errpfx(dbenv, rpmdb->db_errpfx);
@@ -747,10 +747,7 @@ static int db3open(rpmdb rpmdb, rpmTag rpmtag, dbiIndex * dbip)
        rc = db_create(&db, dbenv, dbi->dbi_cflags);
        rc = cvtdberr(dbi, "db_create", rc, _debug);
        if (rc == 0 && db != NULL) {
-
-           if (rc == 0 &&
-                       rpmdb->db_malloc && rpmdb->db_realloc && rpmdb->db_free)
-           {
+           if (rc == 0 && !dbi->dbi_use_dbenv) {
                rc = db->set_alloc(db,
                        rpmdb->db_malloc, rpmdb->db_realloc, rpmdb->db_free);
                rc = cvtdberr(dbi, "db->set_alloc", rc, _debug);
index 1b37723..1bce765 100644 (file)
@@ -920,6 +920,9 @@ rpmdb newRpmdb(const char * root,
     db->db_remove_env = (!rstreq(db->db_root, "/") ? 1 : 0);
     db->db_filter_dups = _db_filter_dups;
     db->db_ndbi = dbiTags.max;
+    db->db_malloc = rmalloc;
+    db->db_realloc = rrealloc;
+    db->db_free = NULL; /* XXX rfree() prototype differs from free() */
     db->_dbi = xcalloc(db->db_ndbi, sizeof(*db->_dbi));
     db->nrefs = 0;
     return rpmdbLink(db, RPMDBG_M("rpmdbCreate"));