/[imapfilter]/imapfilter/buffer.c
ViewVC logotype

Contents of /imapfilter/buffer.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (show annotations)
Fri Feb 13 13:18:37 2004 UTC (20 years, 1 month ago) by lefcha
Branch: MAIN
CVS Tags: HEAD
Changes since 1.5: +3 -0 lines
File MIME type: text/plain
Insert an empty line if the function has no local variables.

1 #include <stdio.h>
2
3 #include "config.h"
4 #include "imapfilter.h"
5 #include "buffer.h"
6
7
8 /*
9 * Initialize buffer.
10 */
11 void
12 buffer_init(buffer_t * buf)
13 {
14
15 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 buffer_reset(buffer_t * buf)
26 {
27
28 *buf->data = '\0';
29 }
30
31
32 /*
33 * Check if the buffer has enough space to store data and reallocate memory if
34 * needed.
35 */
36 void
37 buffer_check(buffer_t * buf, size_t n)
38 {
39
40 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