]> git.tdb.fi Git - gldbg.git/blob - source/tmpalloc.c
Replace per-file license notices with License.txt
[gldbg.git] / source / tmpalloc.c
1 #include <stdlib.h>
2 #include "tmpalloc.h"
3
4 static void *buffer = 0;
5 static unsigned buf_size = 8192;
6 static unsigned offset = 0;
7
8 void *tmpalloc(unsigned size)
9 {
10         void *ptr;
11         if(!buffer)
12                 buffer = malloc(buf_size);
13         if(offset+size>buf_size)
14                 offset = 0;
15         ptr = (char *)buffer+offset;
16         offset += size;
17         return ptr;
18 }
19
20 void tmpfree()
21 {
22         free(buffer);
23         buffer = 0;
24         offset = 0;
25 }