Fixed newline characters throughout the code
[com/gs-lite.git] / src / lib / gscpaux / block_allocator.h
1 // Distributed under the MIT license. Copyright (c) 2010, Ivan Vashchaev
2
3 #ifndef BLOCK_ALLOCATOR_H
4 #define BLOCK_ALLOCATOR_H
5
6 class block_allocator
7 {
8 private:
9         struct block
10         {
11                 size_t size;
12                 size_t used;
13                 char *buffer;
14                 block *next;
15         };
16
17         block *m_head;
18         size_t m_blocksize;
19
20         block_allocator(const block_allocator &);
21         block_allocator &operator=(block_allocator &);
22
23 public:
24         block_allocator(size_t blocksize);
25         ~block_allocator();
26
27         // exchange contents with rhs
28         void swap(block_allocator &rhs);
29
30         // allocate memory
31         void *malloc(size_t size);
32
33         // free all allocated blocks
34         void free();
35 };
36
37 #endif