Parent Directory | Revision Log
Insert an empty line if the function has no local variables.
1 | lefcha | 1.3 | #include <stdio.h> |
2 | lefcha | 1.1 | |
3 | lefcha | 1.2 | #include "config.h" |
4 | lefcha | 1.1 | #include "imapfilter.h" |
5 | lefcha | 1.2 | #include "buffer.h" |
6 | lefcha | 1.1 | |
7 | |||
8 | /* | ||
9 | * Initialize buffer. | ||
10 | */ | ||
11 | void | ||
12 | lefcha | 1.5 | buffer_init(buffer_t * buf) |
13 | lefcha | 1.1 | { |
14 | lefcha | 1.6 | |
15 | lefcha | 1.1 | buf->data = (char *)xmalloc(BUFFER_SIZE + 1); |
16 | *buf->data = '\0'; | ||
17 | buf->size = BUFFER_SIZE + 1; | ||
18 | } | ||
19 | |||
20 | |||
21 | /* | ||
22 | * Reset buffer. | ||
23 | */ | ||
24 | void | ||
25 | lefcha | 1.5 | buffer_reset(buffer_t * buf) |
26 | lefcha | 1.1 | { |
27 | lefcha | 1.6 | |
28 | lefcha | 1.1 | *buf->data = '\0'; |
29 | } | ||
30 | |||
31 | |||
32 | /* | ||
33 | lefcha | 1.4 | * Check if the buffer has enough space to store data and reallocate memory if |
34 | * needed. | ||
35 | lefcha | 1.1 | */ |
36 | void | ||
37 | lefcha | 1.5 | buffer_check(buffer_t * buf, size_t n) |
38 | lefcha | 1.1 | { |
39 | lefcha | 1.6 | |
40 | lefcha | 1.1 | while (n >= buf->size) { |
41 | buf->size += BUFFER_SIZE; | ||
42 | buf->data = (char *)xrealloc(buf->data, buf->size); | ||
43 | } | ||
44 | } |
webmaster@linux.gr | ViewVC Help |
Powered by ViewVC 1.1.26 |