summaryrefslogtreecommitdiffstats
path: root/bpf.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-05-15 12:15:06 +0000
committerRoy Marples <roy@marples.name>2008-05-15 12:15:06 +0000
commit811d4272b54fa4712bf341fdd1654e3618063a77 (patch)
treea6bfbba0cc4ecf636050896bb333723b538b13a1 /bpf.c
parent3581b92aa447e9a29952aafc13d74aaa38415abf (diff)
downloaddhcpcd-811d4272b54fa4712bf341fdd1654e3618063a77.tar.xz
Only alloc a buffer if size is different.
Diffstat (limited to 'bpf.c')
-rw-r--r--bpf.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/bpf.c b/bpf.c
index 46a08c55..a674069e 100644
--- a/bpf.c
+++ b/bpf.c
@@ -92,9 +92,12 @@ open_socket(struct interface *iface, int protocol)
/* Get the required BPF buffer length from the kernel. */
if (ioctl(fd, BIOCGBLEN, &buf_len) == -1)
goto eexit;
- iface->buffer_size = buf_len;
- iface->buffer = xmalloc(buf_len);
- iface->buffer_len = iface->buffer_pos = 0;
+ if (iface->buffer_size != buf_len) {
+ free(iface->buffer);
+ iface->buffer_size = buf_len;
+ iface->buffer = xmalloc(buf_len);
+ iface->buffer_len = iface->buffer_pos = 0;
+ }
#ifdef BIOCIMMEDIATE
flags = 1;