diff options
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r-- | usr.sbin/bgpd/bgpd.h | 3 | ||||
-rw-r--r-- | usr.sbin/bgpd/buffer.c | 19 |
2 files changed, 20 insertions, 2 deletions
diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h index 38d719cf7d8..b860d8390cd 100644 --- a/usr.sbin/bgpd/bgpd.h +++ b/usr.sbin/bgpd/bgpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.h,v 1.206 2006/08/23 08:13:04 claudio Exp $ */ +/* $OpenBSD: bgpd.h,v 1.207 2006/08/27 13:40:21 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -689,6 +689,7 @@ int bgpd_filternexthop(struct kroute *, struct kroute6 *); /* buffer.c */ struct buf *buf_open(size_t); +struct buf *buf_grow(struct buf *, size_t); int buf_add(struct buf *, const void *, size_t); void *buf_reserve(struct buf *, size_t); int buf_close(struct msgbuf *, struct buf *); diff --git a/usr.sbin/bgpd/buffer.c b/usr.sbin/bgpd/buffer.c index 8d326d9615e..eedea29220b 100644 --- a/usr.sbin/bgpd/buffer.c +++ b/usr.sbin/bgpd/buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: buffer.c,v 1.34 2006/04/21 08:51:46 claudio Exp $ */ +/* $OpenBSD: buffer.c,v 1.35 2006/08/27 13:40:21 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -48,6 +48,23 @@ buf_open(size_t len) return (buf); } +struct buf * +buf_grow(struct buf *buf, size_t len) +{ + void *p; + + if ((p = realloc(buf->buf, buf->size + len)) == NULL) { + free(buf->buf); + free(buf); + return (NULL); + } + + buf->buf = p; + buf->size += len; + + return (buf); +} + int buf_add(struct buf *buf, const void *data, size_t len) { |