~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/memory/root.h

  • Committer: patrick crews
  • Date: 2011-06-08 03:02:27 UTC
  • mto: This revision was merged to the branch mainline in revision 2329.
  • Revision ID: gleebix@gmail.com-20110608030227-updkyv2652zvfajc
Initial voodoo worked to give us a crashme mode.  Need docs still

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 * @brief Memory root declarations
19
19
 */
20
20
 
21
 
#ifndef DRIZZLED_MEMORY_ROOT_H
22
 
#define DRIZZLED_MEMORY_ROOT_H
 
21
 
 
22
 
 
23
#pragma once
23
24
 
24
25
#include <cstddef>
25
 
 
 
26
#include <drizzled/common_fwd.h>
26
27
#include <drizzled/definitions.h>
 
28
#include <drizzled/visibility.h>
27
29
 
28
 
namespace drizzled
29
 
{
 
30
namespace drizzled {
30
31
 
31
32
/**
32
33
 * @namespace drizzled::memory
36
37
 * comment on the namespace Doxygen won't extract any documentation for
37
38
 * namespace members.
38
39
 */
39
 
namespace memory
40
 
{
 
40
namespace memory {
41
41
 
42
42
static const int KEEP_PREALLOC= 1;
43
43
/* move used to free list and reuse them */
44
44
static const int MARK_BLOCKS_FREE= 2;
45
45
 
46
 
namespace internal
47
 
{
 
46
namespace internal {
48
47
 
49
48
class UsedMemory
50
49
{                          /* struct for once_alloc (block) */
58
57
 
59
58
static const size_t ROOT_MIN_BLOCK_SIZE= (MALLOC_OVERHEAD + sizeof(internal::UsedMemory) + 8);
60
59
 
61
 
 
62
 
 
63
 
class Root
 
60
class DRIZZLED_API Root
64
61
{
65
62
public:
66
63
 
119
116
  void (*error_handler)(void);
120
117
  void reset_root_defaults(size_t block_size, size_t prealloc_size);
121
118
  void *alloc_root(size_t Size);
 
119
  inline void *allocate(size_t Size)
 
120
  {
 
121
    return alloc_root(Size);
 
122
  }
122
123
  void mark_blocks_free();
123
124
  void *memdup_root(const void *str, size_t len);
124
125
  char *strdup_root(const char *str);
 
126
 
125
127
  char *strmake_root(const char *str,size_t len);
126
128
  void init_alloc_root(size_t block_size= ROOT_MIN_BLOCK_SIZE);
127
129
 
 
130
  inline void *duplicate(const void *str, size_t len)
 
131
  {
 
132
    return memdup_root(str, len);
 
133
  }
 
134
 
128
135
  inline bool alloc_root_inited()
129
136
  {
130
137
    return min_malloc != 0;
136
143
} /* namespace memory */
137
144
} /* namespace drizzled */
138
145
 
139
 
#endif /* DRIZZLED_MEMORY_ROOT_H */