[ovs-dev] [PATCH 1/2] ofpbuf: New function ofpbuf_push_zeros().
Justin Pettit
jpettit at nicira.com
Sat Apr 24 08:29:35 UTC 2010
Looks good.
--Justin
On Apr 9, 2010, at 12:38 PM, Ben Pfaff wrote:
> ---
> lib/ofpbuf.c | 13 ++++++++++++-
> lib/ofpbuf.h | 3 ++-
> 2 files changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/lib/ofpbuf.c b/lib/ofpbuf.c
> index 9cb2ceb..1621bcc 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)
> {
> diff --git a/lib/ofpbuf.h b/lib/ofpbuf.h
> index 9072cc4..736b8f5 100644
> --- a/lib/ofpbuf.h
> +++ b/lib/ofpbuf.h
> @@ -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.
> @@ -62,6 +62,7 @@ void *ofpbuf_put_zeros(struct ofpbuf *, size_t);
> void *ofpbuf_put(struct ofpbuf *, const void *, size_t);
> void ofpbuf_reserve(struct ofpbuf *, size_t);
> void *ofpbuf_push_uninit(struct ofpbuf *b, size_t);
> +void *ofpbuf_push_zeros(struct ofpbuf *, size_t);
> void *ofpbuf_push(struct ofpbuf *b, const void *, size_t);
>
> size_t ofpbuf_headroom(const struct ofpbuf *);
> --
> 1.6.6.1
>
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev_openvswitch.org
More information about the dev
mailing list