diff options
author | David Tardon <dtardon@redhat.com> | 2023-04-21 15:06:28 +0200 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2023-04-27 21:42:38 +0200 |
commit | 12da8805e7b1112f026971be81364d04b07dd405 (patch) | |
tree | fddcf7456df13431974624efe8bab7d577b63d59 /src | |
parent | initctl: use _cleanup_ (diff) | |
download | systemd-12da8805e7b1112f026971be81364d04b07dd405.tar.xz systemd-12da8805e7b1112f026971be81364d04b07dd405.zip |
transaction: modernize transaction_free()
Diffstat (limited to 'src')
-rw-r--r-- | src/core/transaction.c | 8 | ||||
-rw-r--r-- | src/core/transaction.h | 2 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/core/transaction.c b/src/core/transaction.c index 059558ebc0..0038d541b3 100644 --- a/src/core/transaction.c +++ b/src/core/transaction.c @@ -1199,8 +1199,12 @@ Transaction *transaction_new(bool irreversible) { return tr; } -void transaction_free(Transaction *tr) { +Transaction *transaction_free(Transaction *tr) { + if (!tr) + return NULL; + assert(hashmap_isempty(tr->jobs)); hashmap_free(tr->jobs); - free(tr); + + return mfree(tr); } diff --git a/src/core/transaction.h b/src/core/transaction.h index c431271eb2..5258e27106 100644 --- a/src/core/transaction.h +++ b/src/core/transaction.h @@ -16,7 +16,7 @@ struct Transaction { }; Transaction *transaction_new(bool irreversible); -void transaction_free(Transaction *tr); +Transaction *transaction_free(Transaction *tr); void transaction_add_propagate_reload_jobs(Transaction *tr, Unit *unit, Job *by, bool ignore_order, sd_bus_error *e); int transaction_add_job_and_dependencies( |