From fbb94768cb579f85416333f98a0fa655e10f88fc Mon Sep 17 00:00:00 2001 From: Prashanth Pai Date: Fri, 22 Feb 2013 15:52:29 +0530 Subject: iobuf: Added a function iobref_clear Original-author: Venky Shankar Change-Id: Ibf861db6c1b084b798d210962344487a1919aad2 BUG: 921942 Signed-off-by: Prashanth Pai Reviewed-on: http://review.gluster.org/4595 Reviewed-by: Jeff Darcy Tested-by: Gluster Build System --- libglusterfs/src/iobuf.c | 23 +++++++++++++++++++++++ libglusterfs/src/iobuf.h | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/iobuf.c b/libglusterfs/src/iobuf.c index 86bf697e8..a89e96267 100644 --- a/libglusterfs/src/iobuf.c +++ b/libglusterfs/src/iobuf.c @@ -841,6 +841,29 @@ out: } +void +iobref_clear (struct iobref *iobref) +{ + int i = 0; + + GF_VALIDATE_OR_GOTO ("iobuf", iobref, out); + + for (; i < GF_IOBREF_IOBUF_COUNT; i++) { + if (iobref->iobrefs[i] != NULL) { + iobuf_unref (iobref->iobrefs[i]); + } else { + /** iobuf's are attched serially */ + break; + } + } + + iobref_unref (iobref); + + out: + return; +} + + int __iobref_add (struct iobref *iobref, struct iobuf *iobuf) { diff --git a/libglusterfs/src/iobuf.h b/libglusterfs/src/iobuf.h index b9c2a3807..5595309e1 100644 --- a/libglusterfs/src/iobuf.h +++ b/libglusterfs/src/iobuf.h @@ -150,7 +150,7 @@ struct iobref *iobref_ref (struct iobref *iobref); void iobref_unref (struct iobref *iobref); int iobref_add (struct iobref *iobref, struct iobuf *iobuf); int iobref_merge (struct iobref *to, struct iobref *from); - +void iobref_clear (struct iobref *iobref); size_t iobuf_size (struct iobuf *iobuf); size_t iobref_size (struct iobref *iobref); -- cgit