]> git.ipfire.org Git - pakfire.git/commitdiff
libpakfire: Make pakfire_unref the same style as others
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 15 Jan 2018 23:40:23 +0000 (00:40 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 15 Jan 2018 23:40:23 +0000 (00:40 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/include/pakfire/pakfire.h
src/libpakfire/pakfire.c

index b892674a3a087e71d3705b914ad357d26e26196c..0e8a8b94f818d85232114ddf4084c560f76be1b8 100644 (file)
@@ -28,7 +28,7 @@ int pakfire_init();
 Pakfire pakfire_create(const char* path, const char* arch);
 
 Pakfire pakfire_ref(Pakfire pakfire);
-void pakfire_unref(Pakfire pakfire);
+Pakfire pakfire_unref(Pakfire pakfire);
 
 const char* pakfire_get_path(Pakfire pakfire);
 const char* pakfire_get_arch(Pakfire pakfire);
index d6a82589dbe8a39233d89a1c0d62890ddaeb8ac5..fe19d2e15858aec8a43ffd81537d0e6d295ce5b9 100644 (file)
@@ -75,17 +75,23 @@ PAKFIRE_EXPORT Pakfire pakfire_ref(Pakfire pakfire) {
        return pakfire;
 }
 
-PAKFIRE_EXPORT void pakfire_unref(Pakfire pakfire) {
+PAKFIRE_EXPORT Pakfire pakfire_unref(Pakfire pakfire) {
+       if (!pakfire)
+               return NULL;
+
        if (--pakfire->nrefs > 0)
-               return;
+               return pakfire;
 
        pakfire_pool_unref(pakfire->pool);
 
        pakfire_free(pakfire->path);
        pakfire_free(pakfire->arch);
 
-       DEBUG("Pakfire released at %p\n", pakfire);
        pakfire_free(pakfire);
+
+       DEBUG("Pakfire released at %p\n", pakfire);
+
+       return NULL;
 }
 
 PAKFIRE_EXPORT const char* pakfire_get_path(Pakfire pakfire) {