[ovs-dev] [PATCH 2/8] lib/ofpbuf: refactor ofpbuf_use__() API

Andy Zhou azhou at nicira.com
Wed Aug 12 00:55:08 UTC 2015


Add the size to its parameter list.

Signed-off-by: Andy Zhou <azhou at nicira.com>
---
 lib/ofpbuf.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/lib/ofpbuf.c b/lib/ofpbuf.c
index 05b513c..9b9d6b2 100644
--- a/lib/ofpbuf.c
+++ b/lib/ofpbuf.c
@@ -33,12 +33,12 @@ ofpbuf_init__(struct ofpbuf *b, size_t allocated, enum ofpbuf_source source)
 }
 
 static void
-ofpbuf_use__(struct ofpbuf *b, void *base, size_t allocated,
+ofpbuf_use__(struct ofpbuf *b, void *base, size_t allocated, size_t size,
              enum ofpbuf_source source)
 {
     b->base = base;
     b->data = base;
-    b->size = 0;
+    b->size = size;
 
     ofpbuf_init__(b, allocated, source);
 }
@@ -50,7 +50,7 @@ ofpbuf_use__(struct ofpbuf *b, void *base, size_t allocated,
 void
 ofpbuf_use(struct ofpbuf *b, void *base, size_t allocated)
 {
-    ofpbuf_use__(b, base, allocated, OFPBUF_MALLOC);
+    ofpbuf_use__(b, base, allocated, 0, OFPBUF_MALLOC);
 }
 
 /* Initializes 'b' as an empty ofpbuf that contains the 'allocated' bytes of
@@ -70,7 +70,7 @@ ofpbuf_use(struct ofpbuf *b, void *base, size_t allocated)
 void
 ofpbuf_use_stack(struct ofpbuf *b, void *base, size_t allocated)
 {
-    ofpbuf_use__(b, base, allocated, OFPBUF_STACK);
+    ofpbuf_use__(b, base, allocated, 0, OFPBUF_STACK);
 }
 
 /* Initializes 'b' as an empty ofpbuf that contains the 'allocated' bytes of
@@ -90,7 +90,7 @@ ofpbuf_use_stack(struct ofpbuf *b, void *base, size_t allocated)
 void
 ofpbuf_use_stub(struct ofpbuf *b, void *base, size_t allocated)
 {
-    ofpbuf_use__(b, base, allocated, OFPBUF_STUB);
+    ofpbuf_use__(b, base, allocated, 0, OFPBUF_STUB);
 }
 
 /* Initializes 'b' as an ofpbuf whose data starts at 'data' and continues for
@@ -103,8 +103,7 @@ ofpbuf_use_stub(struct ofpbuf *b, void *base, size_t allocated)
 void
 ofpbuf_use_const(struct ofpbuf *b, const void *data, size_t size)
 {
-    ofpbuf_use__(b, CONST_CAST(void *, data), size, OFPBUF_STACK);
-    b->size = size;
+    ofpbuf_use__(b, CONST_CAST(void *, data), size, size, OFPBUF_STACK);
 }
 
 /* Initializes 'b' as an empty ofpbuf with an initial capacity of 'size'
-- 
1.9.1




More information about the dev mailing list