From 83cc3705d934eb111f49830b5872ab1a0d5c6765 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 24 Dec 2008 15:09:57 -0800 Subject: [PATCH] New function ofpbuf_clone_data(). --- lib/ofpbuf.c | 13 +++++++++---- lib/ofpbuf.h | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/ofpbuf.c b/lib/ofpbuf.c index 77631e1d..ab469dbf 100644 --- a/lib/ofpbuf.c +++ b/lib/ofpbuf.c @@ -92,11 +92,16 @@ ofpbuf_new(size_t size) } struct ofpbuf * -ofpbuf_clone(const struct ofpbuf *buffer) +ofpbuf_clone(const struct ofpbuf *buffer) { - /* FIXME: reference counting. */ - struct ofpbuf *b = ofpbuf_new(buffer->size); - ofpbuf_put(b, buffer->data, buffer->size); + return ofpbuf_clone_data(buffer->data, buffer->size); +} + +struct ofpbuf * +ofpbuf_clone_data(const void *data, size_t size) +{ + struct ofpbuf *b = ofpbuf_new(size); + ofpbuf_put(b, data, size); return b; } diff --git a/lib/ofpbuf.h b/lib/ofpbuf.h index 0e94e35b..f3a94c2c 100644 --- a/lib/ofpbuf.h +++ b/lib/ofpbuf.h @@ -62,6 +62,7 @@ void ofpbuf_reinit(struct ofpbuf *, size_t); struct ofpbuf *ofpbuf_new(size_t); struct ofpbuf *ofpbuf_clone(const struct ofpbuf *); +struct ofpbuf *ofpbuf_clone_data(const void *, size_t); void ofpbuf_delete(struct ofpbuf *); void *ofpbuf_at(const struct ofpbuf *, size_t offset, size_t size); -- 2.30.2