"SfR Fresh" - the SfR Freeware/Shareware Archive 
As a special service "SfR Fresh" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting with prefixed line numbers.
Alternatively you can here view or download the uninterpreted source code file.
That can be also achieved for any archive member file by clicking within an archive contents listing on the first character of the file(path) respectively on the according byte size field.
1 #include <stdio.h>
2
3 #include "imapfilter.h"
4 #include "buffer.h"
5
6
7 /*
8 * Initialize buffer.
9 */
10 void
11 buffer_init(buffer *buf, size_t n)
12 {
13
14 buf->data = (char *)xmalloc((n + 1) * sizeof(char));
15 *buf->data = '\0';
16 buf->len = 0;
17 buf->size = n;
18 }
19
20
21 /*
22 * Free allocated memory of buffer.
23 */
24 void
25 buffer_free(buffer *buf)
26 {
27
28 if (!buf->data)
29 return;
30
31 xfree(buf->data);
32 buf->data = NULL;
33 }
34
35
36 /*
37 * Reset buffer.
38 */
39 void
40 buffer_reset(buffer *buf)
41 {
42
43 *buf->data = '\0';
44 buf->len = 0;
45 }
46
47
48 /*
49 * Check if the buffer has enough space to store data and reallocate memory if
50 * needed.
51 */
52 void
53 buffer_check(buffer *buf, size_t n)
54 {
55
56 while (n > buf->size) {
57 buf->size *= 2;
58 buf->data = (char *)xrealloc(buf->data, buf->size + 1);
59 }
60 }