3 static Bufblock *freelist;
13 freelist = freelist->next;
15 p = (Bufblock *) Malloc(sizeof(Bufblock));
16 p->start = Malloc(QUANTA*sizeof(*p->start));
17 p->end = p->start+QUANTA;
19 p->current = p->start;
39 n = p->end-p->start+QUANTA;
40 /* search the free list for a big buffer */
41 for (f = freelist; f; f = f->next) {
42 if (f->end-f->start >= n) {
43 memcpy(f->start, p->start, p->end-p->start);
50 f->current = f->start;
54 if (!f) { /* not found - grow it */
55 p->start = Realloc(p->start, n);
58 p->current = p->start+n-QUANTA;
62 bufcpy(Bufblock *buf, char *cp, int n)
70 insert(Bufblock *buf, int c)
73 if (buf->current >= buf->end)
79 rinsert(Bufblock *buf, Rune r)
84 if (buf->current+n > buf->end)
86 runetochar(buf->current, &r);