From 4ac6dbe630d84edc0c622fefd4a48ac3f96814e8 Mon Sep 17 00:00:00 2001 From: Andy Zhou Date: Tue, 11 Aug 2015 14:08:42 -0700 Subject: [PATCH] lib/ofpbuf: refactor ofpbuf_use__() API Add the size to its parameter list. Signed-off-by: Andy Zhou Acked-by: Ben Pfaff --- lib/ofpbuf.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/ofpbuf.c b/lib/ofpbuf.c index 05b513cc1..9b9d6b2d9 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' -- 2.20.1