summaryrefslogtreecommitdiff
path: root/lib/ofpbuf.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2010-04-09 12:36:16 -0700
committerBen Pfaff <blp@nicira.com>2010-04-26 14:57:49 -0700
commit30f07f1a5e2a021d8e05167b5db93968a2036033 (patch)
tree461289d37bc164e57195122b9ec1c8bbe7de2971 /lib/ofpbuf.c
parent11bbff1b79a97c377021560b8a262af95a0dd1b9 (diff)
downloadopenvswitch-30f07f1a5e2a021d8e05167b5db93968a2036033.tar.gz
ofpbuf: New function ofpbuf_push_zeros().
Diffstat (limited to 'lib/ofpbuf.c')
-rw-r--r--lib/ofpbuf.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/ofpbuf.c b/lib/ofpbuf.c
index 9cb2ceb80..1621bcc19 100644
--- a/lib/ofpbuf.c
+++ b/lib/ofpbuf.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2009 Nicira Networks.
+ * Copyright (c) 2008, 2009, 2010 Nicira Networks.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -219,6 +219,17 @@ ofpbuf_push_uninit(struct ofpbuf *b, size_t size)
return b->data;
}
+/* Prefixes 'size' zeroed bytes to the head end of 'b'. 'b' must have at least
+ * 'size' bytes of headroom. Returns a pointer to the first byte of the data's
+ * location in the ofpbuf. */
+void *
+ofpbuf_push_zeros(struct ofpbuf *b, size_t size)
+{
+ void *dst = ofpbuf_push_uninit(b, size);
+ memset(dst, 0, size);
+ return dst;
+}
+
void *
ofpbuf_push(struct ofpbuf *b, const void *p, size_t size)
{