Update path to xapp descriptor. Add schema parser library
[ric-app/mc.git] / schemaparser / block_allocator.h
1 // Distributed under the MIT license. Copyright (c) 2010, Ivan Vashchaev
2
3
4 #ifndef BLOCK_ALLOCATOR_H
5 #define BLOCK_ALLOCATOR_H
6
7 namespace mc_json{
8 class block_allocator
9 {
10 private:
11         struct block
12         {
13                 size_t size;
14                 size_t used;
15                 char *buffer;
16                 block *next;
17         };
18
19         block *m_head;
20         size_t m_blocksize;
21
22         block_allocator(const block_allocator &);
23         block_allocator &operator=(block_allocator &);
24
25 public:
26         block_allocator(size_t blocksize);
27         ~block_allocator();
28
29         // exchange contents with rhs
30         void swap(block_allocator &rhs);
31
32         // allocate memory
33         void *malloc(size_t size);
34
35         // free all allocated blocks
36         void free();
37 };
38 }
39
40 #endif