From: Ben Pfaff Date: Wed, 24 Dec 2008 23:09:57 +0000 (-0800) Subject: New function ofpbuf_clone_data(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=83cc3705d934eb111f49830b5872ab1a0d5c6765;p=openvswitch New function ofpbuf_clone_data(). --- 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);