X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fofpbuf.c;h=1621bcc198128e9140323a32891ab9d99e9cef82;hb=bfb1f2d5cbb9ef82f2def2f41f5ff8a8f02b5bbc;hp=9cb2ceb80f7adc0d03b906d3b6552a78a65138d3;hpb=0ab8e15fd7b5618c0c513c69ab6fd4155eb13452;p=openvswitch diff --git a/lib/ofpbuf.c b/lib/ofpbuf.c index 9cb2ceb8..1621bcc1 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) {