~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/memory/root.h

  • Committer: Mark Atwood
  • Date: 2011-06-24 02:13:02 UTC
  • mfrom: (2318.6.56 rf)
  • Revision ID: me@mark.atwood.name-20110624021302-y9oiksid220xan9s
mergeĀ lp:~olafvdspek/drizzle/refactor14

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
/* move used to free list and reuse them */
41
41
static const int MARK_BLOCKS_FREE= 2;
42
42
 
43
 
namespace internal {
44
 
 
45
 
class UsedMemory
46
 
{                          /* struct for once_alloc (block) */
47
 
public:
48
 
  UsedMemory *next;        /* Next block in use */
49
 
  size_t left;             /* memory left in block  */            
50
 
  size_t size;             /* size of block */
51
 
};
52
 
 
 
43
namespace internal 
 
44
{
 
45
  class UsedMemory
 
46
  {                        /* struct for once_alloc (block) */
 
47
  public:
 
48
    UsedMemory *next;      /* Next block in use */
 
49
    size_t left;                   /* memory left in block  */            
 
50
    size_t size;                   /* size of block */
 
51
  };
53
52
}
54
53
 
55
54
static const size_t ROOT_MIN_BLOCK_SIZE= (MALLOC_OVERHEAD + sizeof(internal::UsedMemory) + 8);
57
56
class DRIZZLED_API Root
58
57
{
59
58
public:
60
 
 
61
59
  Root() :
62
60
    free(0),
63
61
    used(0),
107
105
  unsigned int first_block_usage;
108
106
 
109
107
  void reset_defaults(size_t block_size, size_t prealloc_size);
110
 
  void* alloc(size_t Size);
 
108
  unsigned char* alloc(size_t Size);
111
109
  void mark_blocks_free();
112
110
  void* memdup(const void*, size_t);
113
111
  char* strdup(const char*);
122
120
    return min_malloc != 0;
123
121
  }
124
122
  void free_root(myf MyFLAGS);
125
 
  void* multi_alloc_root(int unused, ...);
126
 
 
127
 
  void* alloc_root(size_t Size)
128
 
  {
129
 
    return alloc(Size);
130
 
  }
 
123
  void* multi_alloc(int unused, ...);
131
124
 
132
125
  void* calloc(size_t size)
133
126
  {
134
 
    void* ptr= alloc_root(size);
 
127
    void* ptr= alloc(size);
135
128
    memset(ptr, 0, size);
136
129
    return ptr;
137
130
  }
140
133
} /* namespace memory */
141
134
} /* namespace drizzled */
142
135
 
 
136
inline void* operator new(size_t size, drizzled::memory::Root& root)
 
137
{
 
138
  return root.alloc(size);
 
139
}
 
140