Change commit_ref_transaction() to also free the associated data, to absolve the caller from having to do it. Signed-off-by: Michael Haggerty <mhagger@xxxxxxxxxxxx> --- builtin/update-ref.c | 1 - refs.c | 1 + refs.h | 11 ++++++----- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/builtin/update-ref.c b/builtin/update-ref.c index ffed061..b33288c 100644 --- a/builtin/update-ref.c +++ b/builtin/update-ref.c @@ -346,7 +346,6 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix) update_refs_stdin(); ret = commit_ref_transaction(transaction, msg, UPDATE_REFS_DIE_ON_ERR); - free_ref_transaction(transaction); return ret; } diff --git a/refs.c b/refs.c index 1fd38b0..d83fc7b 100644 --- a/refs.c +++ b/refs.c @@ -3471,6 +3471,7 @@ cleanup: unlock_ref(updates[i]->lock); free(updates); free(delnames); + free_ref_transaction(transaction); return ret; } diff --git a/refs.h b/refs.h index cc24213..754894b 100644 --- a/refs.h +++ b/refs.h @@ -210,14 +210,15 @@ enum action_on_err { /* * Allocate and initialize a ref_transaction object. The object must - * be freed by calling free_ref_transaction(). + * be freed by calling commit_ref_transaction() or + * free_ref_transaction(). */ struct ref_transaction *create_ref_transaction(void); /* - * Free a ref_transaction and all associated data. This function does - * not commit the transaction; that must be done first (if desired) by - * calling commit_ref_transaction(). + * Free a ref_transaction and all associated data. This function + * should be called to free a ref_transaction that will not be + * committed. */ void free_ref_transaction(struct ref_transaction *transaction); @@ -264,7 +265,7 @@ void queue_delete_ref(struct ref_transaction *transaction, const char *refname, /* * Commit all of the changes that have been queued in transaction, as * atomically as possible. Return a nonzero value if there is a - * problem. The transaction is unmodified by this function. + * problem. The transaction is freed by this function. */ int commit_ref_transaction(struct ref_transaction *transaction, const char *msg, enum action_on_err onerr); -- 1.9.0 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html