root/trunk/src/shared/Config/dotconfpp/mempool.h @ 88

Revision 2, 0.7 kB (checked in by yumileroy, 17 years ago)

[svn] * Proper SVN structure

Original author: Neo2003
Date: 2008-10-02 16:23:55-05:00

Line 
1
2
3
4#ifndef ASYNC_DNS_MEMPOOL_H
5#define ASYNC_DNS_MEMPOOL_H
6
7#include <stdlib.h>
8#include <string.h>
9#include <sys/types.h>
10
11#undef free
12#undef calloc
13#undef strdup
14
15class AsyncDNSMemPool
16{
17private:
18    struct PoolChunk {
19        void * pool;
20        size_t pos;
21        size_t size;
22
23        PoolChunk(size_t _size);
24        ~PoolChunk();
25    };
26    PoolChunk ** chunks;
27    size_t chunksCount;
28    size_t defaultSize;
29
30    size_t poolUsage;
31    size_t poolUsageCounter;
32
33    void addNewChunk(size_t size);
34
35public:
36    AsyncDNSMemPool(size_t _defaultSize = 4096);
37    virtual ~AsyncDNSMemPool();
38
39    int initialize();
40    void free();
41    void * alloc(size_t size);
42    void * calloc(size_t size);
43    char * strdup(const char *str);
44};
45
46#endif
Note: See TracBrowser for help on using the browser.