]> git.ipfire.org Git - pakfire.git/commitdiff
libpakfire: Log allocation and release of refcounted objects
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 14 Jan 2018 17:07:21 +0000 (18:07 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 14 Jan 2018 17:07:21 +0000 (18:07 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/package.c
src/libpakfire/pool.c
src/libpakfire/transaction.c

index 4fbda0bfd375a4a644128479a1ea395a8f66387b..742a75e2722b3a133c34097fd5f5898eac8ea3c2 100644 (file)
@@ -33,6 +33,7 @@
 #include <pakfire/constants.h>
 #include <pakfire/file.h>
 #include <pakfire/i18n.h>
+#include <pakfire/logging.h>
 #include <pakfire/package.h>
 #include <pakfire/packagecache.h>
 #include <pakfire/pool.h>
@@ -64,6 +65,8 @@ static void pakfire_package_add_self_provides(PakfirePool pool, PakfirePackage p
 PAKFIRE_EXPORT PakfirePackage pakfire_package_create(PakfirePool pool, Id id) {
        PakfirePackage pkg = pakfire_calloc(1, sizeof(*pkg));
        if (pkg) {
+               DEBUG("Allocated Package at %p\n", pkg);
+
                pkg->pool = pakfire_pool_ref(pool);
                pkg->id = id;
 
@@ -90,6 +93,8 @@ static void pakfire_package_free(PakfirePackage pkg) {
        pakfire_pool_unref(pkg->pool);
        pakfire_package_filelist_remove(pkg);
        pakfire_free(pkg);
+
+       DEBUG("Released Package at %p\n", pkg);
 }
 
 PAKFIRE_EXPORT PakfirePackage pakfire_package_ref(PakfirePackage pkg) {
index f05f7d8099f22981d19bcaa4e8d623d71e9aa75f..a5e85a396ba358baf3145a80b2a418839ae86e02 100644 (file)
@@ -27,6 +27,7 @@
 #include <solv/repo.h>
 
 #include <pakfire/cache.h>
+#include <pakfire/logging.h>
 #include <pakfire/package.h>
 #include <pakfire/packagelist.h>
 #include <pakfire/pakfire.h>
@@ -48,6 +49,7 @@ struct _PakfirePool {
 PAKFIRE_EXPORT PakfirePool pakfire_pool_create(Pakfire pakfire) {
        PakfirePool pool = pakfire_calloc(1, sizeof(*pool));
        if (pool) {
+               DEBUG("Allocated Pool at %p\n", pool);
                pool->nrefs = 1;
 
                // Initialize pool
@@ -82,6 +84,8 @@ static void pakfire_pool_free(PakfirePool pool) {
 
        pool_free(pool->pool);
        pakfire_free(pool);
+
+       DEBUG("Released Pool at %p\n", pool);
 }
 
 PAKFIRE_EXPORT PakfirePool pakfire_pool_ref(PakfirePool pool) {
index badbf31129ddd7f88b7e9526976dc58b5ea7edae..fb9d1a3e39092241437eb7885447328bc7947821 100644 (file)
@@ -42,18 +42,19 @@ struct _PakfireTransaction {
 
 PAKFIRE_EXPORT PakfireTransaction pakfire_transaction_create(PakfirePool pool, Transaction* trans) {
        PakfireTransaction transaction = pakfire_calloc(1, sizeof(*transaction));
-       if (!transaction)
-               return NULL;
-
-       transaction->pool = pakfire_pool_ref(pool);
-       transaction->nrefs = 1;
-
-       // Clone the transaction, so we get independent from what ever called this.
-       if (trans) {
-               transaction->transaction = transaction_create_clone(trans);
-               transaction_order(transaction->transaction, 0);
-       } else {
-               transaction->transaction = transaction_create(trans->pool);
+       if (transaction) {
+               DEBUG("Allocated Transaction at %p\n", transaction);
+               transaction->nrefs = 1;
+
+               transaction->pool = pakfire_pool_ref(pool);
+
+               // Clone the transaction, so we get independent from what ever called this.
+               if (trans) {
+                       transaction->transaction = transaction_create_clone(trans);
+                       transaction_order(transaction->transaction, 0);
+               } else {
+                       transaction->transaction = transaction_create(trans->pool);
+               }
        }
 
        return transaction;
@@ -72,6 +73,8 @@ void pakfire_transaction_free(PakfireTransaction transaction) {
 
        transaction_free(transaction->transaction);
        pakfire_free(transaction);
+
+       DEBUG("Released Transaction at %p\n", transaction);
 }
 
 PAKFIRE_EXPORT PakfireTransaction pakfire_transaction_unref(PakfireTransaction transaction) {