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

Contents of /imapfilter/buffer.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Sun Jul 27 15:53:10 2003 UTC (20 years, 8 months ago) by lefcha
Branch: MAIN
File MIME type: text/plain
Added temporary buffer auxiliary routines.

1 #include <string.h>
2
3 #include "imapfilter.h"
4
5
6 /*
7 * Initialize buffer.
8 */
9 void
10 init_buffer(buffer_t * buf)
11 {
12 buf->data = (char *)xmalloc(BUFFER_SIZE + 1);
13 *buf->data = '\0';
14 buf->size = BUFFER_SIZE + 1;
15 }
16
17
18 /*
19 * Reset buffer.
20 */
21 void
22 reset_buffer(buffer_t * buf)
23 {
24 *buf->data = '\0';
25 }
26
27
28 /*
29 * Check if the buffer has at enough space to store data and reallocate
30 * memory if needed.
31 */
32 void
33 check_buffer(buffer_t * buf, size_t n)
34 {
35 while (n >= buf->size) {
36 buf->size += BUFFER_SIZE;
37 buf->data = (char *)xrealloc(buf->data, buf->size);
38 }
39 }

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26