diff options
Diffstat (limited to 'buffer.c')
-rw-r--r-- | buffer.c | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -12,7 +12,7 @@ | |||
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include "includes.h" | 14 | #include "includes.h" |
15 | RCSID("$OpenBSD: buffer.c,v 1.17 2003/09/16 03:03:47 deraadt Exp $"); | 15 | RCSID("$OpenBSD: buffer.c,v 1.18 2003/09/16 21:02:39 markus Exp $"); |
16 | 16 | ||
17 | #include "xmalloc.h" | 17 | #include "xmalloc.h" |
18 | #include "buffer.h" | 18 | #include "buffer.h" |
@@ -23,8 +23,11 @@ RCSID("$OpenBSD: buffer.c,v 1.17 2003/09/16 03:03:47 deraadt Exp $"); | |||
23 | void | 23 | void |
24 | buffer_init(Buffer *buffer) | 24 | buffer_init(Buffer *buffer) |
25 | { | 25 | { |
26 | buffer->alloc = 4096; | 26 | const u_int len = 4096; |
27 | buffer->buf = xmalloc(buffer->alloc); | 27 | |
28 | buffer->alloc = 0; | ||
29 | buffer->buf = xmalloc(len); | ||
30 | buffer->alloc = len; | ||
28 | buffer->offset = 0; | 31 | buffer->offset = 0; |
29 | buffer->end = 0; | 32 | buffer->end = 0; |
30 | } | 33 | } |
@@ -34,8 +37,10 @@ buffer_init(Buffer *buffer) | |||
34 | void | 37 | void |
35 | buffer_free(Buffer *buffer) | 38 | buffer_free(Buffer *buffer) |
36 | { | 39 | { |
37 | memset(buffer->buf, 0, buffer->alloc); | 40 | if (buffer->alloc > 0) { |
38 | xfree(buffer->buf); | 41 | memset(buffer->buf, 0, buffer->alloc); |
42 | xfree(buffer->buf); | ||
43 | } | ||
39 | } | 44 | } |
40 | 45 | ||
41 | /* | 46 | /* |