Thread (20 messages) flat view 20 messages, 1 author, 2016-06-15
DORMANTno replies REVIEWED: 2 (0M)

Revision v21 of 10 in this series; 2 review trailers.

Revisions (10)
  1. v11 [diff vs current]
  2. v13 [diff vs current]
  3. v14 [diff vs current]
  4. v15 [diff vs current]
  5. v16 [diff vs current]
  6. v17 [diff vs current]
  7. v18 [diff vs current]
  8. v19 [diff vs current]
  9. v20 [diff vs current]
  10. v21 current

[PATCH v21 04/19] refs.c: allow passing NULL to ref_transaction_free

From: Ronnie Sahlberg <hidden>
Date: 2016-06-15 23:01:55
Subsystem: the rest · Maintainer: Linus Torvalds

Allow ref_transaction_free(NULL) as a no-op. This makes ref_transaction_free
easier to use and more similar to plain 'free'.

In particular, it lets us rollback unconditionally as part of cleanup code
after setting 'transaction = NULL' if a transaction has been committed or
rolled back already.

Reviewed-by: Jonathan Nieder <redacted>
Reviewed-by: Michael Haggerty <redacted>
Signed-off-by: Ronnie Sahlberg <redacted>
---
 refs.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/refs.c b/refs.c
index 21ed465..1d6dece 100644
--- a/refs.c
+++ b/refs.c
@@ -3338,6 +3338,9 @@ void ref_transaction_free(struct ref_transaction *transaction)
 {
 	int i;
 
+	if (!transaction)
+		return;
+
 	for (i = 0; i < transaction->nr; i++)
 		free(transaction->updates[i]);
 
-- 
2.0.1.546.gf603308
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help