~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_alloc.cc

  • Committer: Monty Taylor
  • Date: 2009-04-12 08:14:18 UTC
  • mto: (992.1.1 mordred)
  • mto: This revision was merged to the branch mainline in revision 990.
  • Revision ID: mordred@inaugust.com-20090412081418-dc6gh3g3awkrhwov
Merged compress, uncompress and uncompressed_length into one plugin lib. Yay new plugin registration!

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
13
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
15
 
 
16
 
/**
17
 
 * @file
18
 
 * Routines to handle mallocing of results which will be freed the same time 
19
 
 */
20
 
 
21
 
#include "config.h"
22
 
 
23
 
#include "drizzled/internal/my_sys.h"
24
 
#include "drizzled/internal/m_string.h"
25
 
 
26
 
#include <algorithm>
27
 
 
28
 
using namespace std;
29
 
 
30
 
namespace drizzled
31
 
{
32
 
 
33
 
static const unsigned int MAX_BLOCK_TO_DROP= 4096;
34
 
static const unsigned int MAX_BLOCK_USAGE_BEFORE_DROP= 10;
35
 
 
36
 
/**
37
 
 * @brief
38
 
 * Initialize memory root
39
 
 *
40
 
 * @details
41
 
 * This function prepares memory root for further use, sets initial size of
42
 
 * chunk for memory allocation and pre-allocates first block if specified.
43
 
 * Altough error can happen during execution of this function if
44
 
 * pre_alloc_size is non-0 it won't be reported. Instead it will be
45
 
 * reported as error in first alloc_root() on this memory root.
46
 
 *
47
 
 * @param  mem_root       memory root to initialize
48
 
 * @param  block_size     size of chunks (blocks) used for memory allocation
49
 
 *                       (It is external size of chunk i.e. it should include
50
 
 *                      memory required for internal structures, thus it
51
 
 *                      should be no less than memory::ROOT_MIN_BLOCK_SIZE)
52
 
 *
53
 
 */
54
 
void memory::Root::init_alloc_root(size_t block_size_arg)
55
 
{
56
 
  free= used= pre_alloc= 0;
57
 
  min_malloc= 32;
58
 
  block_size= block_size_arg - memory::ROOT_MIN_BLOCK_SIZE;
59
 
  error_handler= 0;
60
 
  block_num= 4;                 /* We shift this with >>2 */
61
 
  first_block_usage= 0;
62
 
}
63
 
 
64
 
memory::Root::~Root()
65
 
{
66
 
}
67
 
 
68
 
 
69
 
/**
70
 
 * @details
71
 
 * Function aligns and assigns new value to block size; then it tries to
72
 
 * reuse one of existing blocks as prealloc block, or malloc new one of
73
 
 * requested size. If no blocks can be reused, all unused blocks are freed
74
 
 * before allocation.
75
 
 *
76
 
 * @param  mem_root        memory root to change defaults of
77
 
 * @param  block_size      new value of block size. Must be greater or equal
78
 
 *                         than ALLOC_ROOT_MIN_BLOCK_SIZE (this value is about
79
 
 *                         68 bytes and depends on platform and compilation flags)
80
 
 * @param pre_alloc_size  new size of preallocated block. If not zero,
81
 
 *                        must be equal to or greater than block size,
82
 
 *                        otherwise means 'no prealloc'.
83
 
 */
84
 
void memory::Root::reset_root_defaults(size_t block_size_arg, size_t pre_alloc_size)
85
 
{
86
 
  block_size= block_size_arg - memory::ROOT_MIN_BLOCK_SIZE;
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
 
 
16
/* Routines to handle mallocing of results which will be freed the same time */
 
17
 
 
18
#include "mysys_priv.h"
 
19
#include <mystrings/m_string.h>
 
20
 
 
21
 
 
22
/*
 
23
  Initialize memory root
 
24
 
 
25
  SYNOPSIS
 
26
    init_alloc_root()
 
27
      mem_root       - memory root to initialize
 
28
      block_size     - size of chunks (blocks) used for memory allocation
 
29
                       (It is external size of chunk i.e. it should include
 
30
                        memory required for internal structures, thus it
 
31
                        should be no less than ALLOC_ROOT_MIN_BLOCK_SIZE)
 
32
      pre_alloc_size - if non-0, then size of block that should be
 
33
                       pre-allocated during memory root initialization.
 
34
 
 
35
  DESCRIPTION
 
36
    This function prepares memory root for further use, sets initial size of
 
37
    chunk for memory allocation and pre-allocates first block if specified.
 
38
    Altough error can happen during execution of this function if
 
39
    pre_alloc_size is non-0 it won't be reported. Instead it will be
 
40
    reported as error in first alloc_root() on this memory root.
 
41
*/
 
42
 
 
43
void init_alloc_root(MEM_ROOT *mem_root, size_t block_size,
 
44
                     size_t )
 
45
{
 
46
  mem_root->free= mem_root->used= mem_root->pre_alloc= 0;
 
47
  mem_root->min_malloc= 32;
 
48
  mem_root->block_size= block_size - ALLOC_ROOT_MIN_BLOCK_SIZE;
 
49
  mem_root->error_handler= 0;
 
50
  mem_root->block_num= 4;                       /* We shift this with >>2 */
 
51
  mem_root->first_block_usage= 0;
 
52
 
 
53
  return;
 
54
}
 
55
 
 
56
 
 
57
/*
 
58
  SYNOPSIS
 
59
    reset_root_defaults()
 
60
    mem_root        memory root to change defaults of
 
61
    block_size      new value of block size. Must be greater or equal
 
62
                    than ALLOC_ROOT_MIN_BLOCK_SIZE (this value is about
 
63
                    68 bytes and depends on platform and compilation flags)
 
64
    pre_alloc_size  new size of preallocated block. If not zero,
 
65
                    must be equal to or greater than block size,
 
66
                    otherwise means 'no prealloc'.
 
67
  DESCRIPTION
 
68
    Function aligns and assigns new value to block size; then it tries to
 
69
    reuse one of existing blocks as prealloc block, or malloc new one of
 
70
    requested size. If no blocks can be reused, all unused blocks are freed
 
71
    before allocation.
 
72
*/
 
73
 
 
74
void reset_root_defaults(MEM_ROOT *mem_root, size_t block_size,
 
75
                         size_t pre_alloc_size)
 
76
{
 
77
  assert(alloc_root_inited(mem_root));
 
78
 
 
79
  mem_root->block_size= block_size - ALLOC_ROOT_MIN_BLOCK_SIZE;
87
80
  if (pre_alloc_size)
88
81
  {
89
 
    size_t size= pre_alloc_size + ALIGN_SIZE(sizeof(memory::internal::UsedMemory));
90
 
    if (not pre_alloc || pre_alloc->size != size)
 
82
    size_t size= pre_alloc_size + ALIGN_SIZE(sizeof(USED_MEM));
 
83
    if (!mem_root->pre_alloc || mem_root->pre_alloc->size != size)
91
84
    {
92
 
      memory::internal::UsedMemory *mem, **prev= &this->free;
 
85
      USED_MEM *mem, **prev= &mem_root->free;
93
86
      /*
94
87
        Free unused blocks, so that consequent calls
95
88
        to reset_root_defaults won't eat away memory.
100
93
        if (mem->size == size)
101
94
        {
102
95
          /* We found a suitable block, no need to do anything else */
103
 
          pre_alloc= mem;
 
96
          mem_root->pre_alloc= mem;
104
97
          return;
105
98
        }
106
 
        if (mem->left + ALIGN_SIZE(sizeof(memory::internal::UsedMemory)) == mem->size)
 
99
        if (mem->left + ALIGN_SIZE(sizeof(USED_MEM)) == mem->size)
107
100
        {
108
101
          /* remove block from the list and free it */
109
102
          *prev= mem->next;
110
 
          std::free(mem);
 
103
          free(mem);
111
104
        }
112
105
        else
113
106
          prev= &mem->next;
114
107
      }
115
108
      /* Allocate new prealloc block and add it to the end of free list */
116
 
      if ((mem= static_cast<memory::internal::UsedMemory *>(malloc(size))))
 
109
      if ((mem= (USED_MEM *) malloc(size)))
117
110
      {
118
111
        mem->size= size;
119
112
        mem->left= pre_alloc_size;
120
113
        mem->next= *prev;
121
 
        *prev= pre_alloc= mem;
 
114
        *prev= mem_root->pre_alloc= mem;
122
115
      }
123
116
      else
124
117
      {
125
 
        pre_alloc= 0;
 
118
        mem_root->pre_alloc= 0;
126
119
      }
127
120
    }
128
121
  }
129
122
  else
130
123
  {
131
 
    pre_alloc= 0;
 
124
    mem_root->pre_alloc= 0;
132
125
  }
133
126
}
134
127
 
135
 
/**
136
 
 * @brief 
137
 
 * Allocate a chunk of memory from the Root structure provided, 
138
 
 * obtaining more memory from the heap if necessary
139
 
 *
140
 
 * @pre
141
 
 * mem_root must have been initialised via init_alloc_root()
142
 
 *
143
 
 * @param  mem_root  The memory Root to allocate from
144
 
 * @param  length    The size of the block to allocate
145
 
 *
146
 
 * @todo Would this be more suitable as a member function on the
147
 
 * Root class?
148
 
 */
149
 
void *memory::Root::alloc_root(size_t length)
 
128
 
 
129
void *alloc_root(MEM_ROOT *mem_root, size_t length)
150
130
{
 
131
  size_t get_size, block_size;
151
132
  unsigned char* point;
152
 
  memory::internal::UsedMemory *next= NULL;
153
 
  memory::internal::UsedMemory **prev;
154
 
  assert(alloc_root_inited());
 
133
  register USED_MEM *next= 0;
 
134
  register USED_MEM **prev;
 
135
  assert(alloc_root_inited(mem_root));
155
136
 
156
137
  length= ALIGN_SIZE(length);
157
 
  if ((*(prev= &this->free)) != NULL)
 
138
  if ((*(prev= &mem_root->free)) != NULL)
158
139
  {
159
140
    if ((*prev)->left < length &&
160
 
        this->first_block_usage++ >= MAX_BLOCK_USAGE_BEFORE_DROP &&
161
 
        (*prev)->left < MAX_BLOCK_TO_DROP)
 
141
        mem_root->first_block_usage++ >= ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP &&
 
142
        (*prev)->left < ALLOC_MAX_BLOCK_TO_DROP)
162
143
    {
163
144
      next= *prev;
164
145
      *prev= next->next;                        /* Remove block from list */
165
 
      next->next= this->used;
166
 
      this->used= next;
167
 
      this->first_block_usage= 0;
 
146
      next->next= mem_root->used;
 
147
      mem_root->used= next;
 
148
      mem_root->first_block_usage= 0;
168
149
    }
169
150
    for (next= *prev ; next && next->left < length ; next= next->next)
170
151
      prev= &next->next;
171
152
  }
172
153
  if (! next)
173
154
  {                                             /* Time to alloc new block */
174
 
    size_t get_size, tmp_block_size;
175
 
 
176
 
    tmp_block_size= this->block_size * (this->block_num >> 2);
177
 
    get_size= length+ALIGN_SIZE(sizeof(memory::internal::UsedMemory));
178
 
    get_size= max(get_size, tmp_block_size);
179
 
 
180
 
    if (!(next = static_cast<memory::internal::UsedMemory *>(malloc(get_size))))
 
155
    block_size= mem_root->block_size * (mem_root->block_num >> 2);
 
156
    get_size= length+ALIGN_SIZE(sizeof(USED_MEM));
 
157
    get_size= cmax(get_size, block_size);
 
158
 
 
159
    if (!(next = (USED_MEM*) malloc(get_size)))
181
160
    {
182
 
      if (this->error_handler)
183
 
        (*this->error_handler)();
184
 
      return NULL;
 
161
      if (mem_root->error_handler)
 
162
        (*mem_root->error_handler)();
 
163
      return((void*) 0);                      /* purecov: inspected */
185
164
    }
186
 
    this->block_num++;
 
165
    mem_root->block_num++;
187
166
    next->next= *prev;
188
167
    next->size= get_size;
189
 
    next->left= get_size-ALIGN_SIZE(sizeof(memory::internal::UsedMemory));
 
168
    next->left= get_size-ALIGN_SIZE(sizeof(USED_MEM));
190
169
    *prev=next;
191
170
  }
192
171
 
193
172
  point= (unsigned char*) ((char*) next+ (next->size-next->left));
194
 
  /** @todo next part may be unneeded due to this->first_block_usage counter*/
195
 
  if ((next->left-= length) < this->min_malloc)
 
173
  /*TODO: next part may be unneded due to mem_root->first_block_usage counter*/
 
174
  if ((next->left-= length) < mem_root->min_malloc)
196
175
  {                                             /* Full block */
197
176
    *prev= next->next;                          /* Remove block from list */
198
 
    next->next= this->used;
199
 
    this->used= next;
200
 
    this->first_block_usage= 0;
 
177
    next->next= mem_root->used;
 
178
    mem_root->used= next;
 
179
    mem_root->first_block_usage= 0;
201
180
  }
202
 
 
203
 
  return point;
 
181
  return((void*) point);
204
182
}
205
183
 
206
184
 
207
 
/**
208
 
 * @brief
209
 
 * Allocate many pointers at the same time.
210
 
 *
211
 
 * @details
212
 
 * The variable arguments are a list of alternating pointers and lengths,
213
 
 * terminated by a null pointer:
214
 
 * @li <tt>char ** pointer1</tt>
215
 
 * @li <tt>uint length1</tt>
216
 
 * @li <tt>char ** pointer2</tt>
217
 
 * @li <tt>uint length2</tt>
218
 
 * @li <tt>...</tt>
219
 
 * @li <tt>NULL</tt>
220
 
 *
221
 
 * @c pointer1, @c pointer2 etc. all point into big allocated memory area
222
 
 *
223
 
 * @param root  Memory root
224
 
 *
225
 
 * @return
226
 
 * A pointer to the beginning of the allocated memory block in case of 
227
 
 * success or NULL if out of memory
228
 
 */
229
 
void *memory::Root::multi_alloc_root(int unused, ...)
 
185
/*
 
186
  Allocate many pointers at the same time.
 
187
 
 
188
  DESCRIPTION
 
189
    ptr1, ptr2, etc all point into big allocated memory area.
 
190
 
 
191
  SYNOPSIS
 
192
    multi_alloc_root()
 
193
      root               Memory root
 
194
      ptr1, length1      Multiple arguments terminated by a NULL pointer
 
195
      ptr2, length2      ...
 
196
      ...
 
197
      NULL
 
198
 
 
199
  RETURN VALUE
 
200
    A pointer to the beginning of the allocated memory block
 
201
    in case of success or NULL if out of memory.
 
202
*/
 
203
 
 
204
void *multi_alloc_root(MEM_ROOT *root, ...)
230
205
{
231
206
  va_list args;
232
207
  char **ptr, *start, *res;
233
208
  size_t tot_length, length;
234
209
 
235
 
  (void)unused; // For some reason Sun Studio registers unused as not used.
236
 
  va_start(args, unused);
 
210
  va_start(args, root);
237
211
  tot_length= 0;
238
212
  while ((ptr= va_arg(args, char **)))
239
213
  {
242
216
  }
243
217
  va_end(args);
244
218
 
245
 
  if (!(start= (char*) this->alloc_root(tot_length)))
246
 
    return(0);
 
219
  if (!(start= (char*) alloc_root(root, tot_length)))
 
220
    return(0);                            /* purecov: inspected */
247
221
 
248
 
  va_start(args, unused);
 
222
  va_start(args, root);
249
223
  res= start;
250
224
  while ((ptr= va_arg(args, char **)))
251
225
  {
259
233
 
260
234
#define TRASH_MEM(X) TRASH(((char*)(X) + ((X)->size-(X)->left)), (X)->left)
261
235
 
262
 
/**
263
 
 * @brief
264
 
 * Mark all data in blocks free for reusage 
265
 
 */
266
 
void memory::Root::mark_blocks_free()
 
236
/* Mark all data in blocks free for reusage */
 
237
 
 
238
static inline void mark_blocks_free(MEM_ROOT* root)
267
239
{
268
 
  memory::internal::UsedMemory *next;
269
 
  memory::internal::UsedMemory **last;
 
240
  register USED_MEM *next;
 
241
  register USED_MEM **last;
270
242
 
271
243
  /* iterate through (partially) free blocks, mark them free */
272
 
  last= &free;
273
 
  for (next= free; next; next= *(last= &next->next))
 
244
  last= &root->free;
 
245
  for (next= root->free; next; next= *(last= &next->next))
274
246
  {
275
 
    next->left= next->size - ALIGN_SIZE(sizeof(memory::internal::UsedMemory));
 
247
    next->left= next->size - ALIGN_SIZE(sizeof(USED_MEM));
276
248
    TRASH_MEM(next);
277
249
  }
278
250
 
279
251
  /* Combine the free and the used list */
280
 
  *last= next= used;
 
252
  *last= next=root->used;
281
253
 
282
254
  /* now go through the used blocks and mark them free */
283
255
  for (; next; next= next->next)
284
256
  {
285
 
    next->left= next->size - ALIGN_SIZE(sizeof(memory::internal::UsedMemory));
 
257
    next->left= next->size - ALIGN_SIZE(sizeof(USED_MEM));
286
258
    TRASH_MEM(next);
287
259
  }
288
260
 
289
261
  /* Now everything is set; Indicate that nothing is used anymore */
290
 
  used= 0;
291
 
  first_block_usage= 0;
 
262
  root->used= 0;
 
263
  root->first_block_usage= 0;
292
264
}
293
265
 
294
 
/**
295
 
 * @brief
296
 
 * Deallocate everything used by memory::alloc_root or just move
297
 
 * used blocks to free list if called with MY_USED_TO_FREE
298
 
 *
299
 
 * @note
300
 
 * One can call this function either with root block initialised with
301
 
 * init_alloc_root() or with a zero:ed block.
302
 
 * It's also safe to call this multiple times with the same mem_root.
303
 
 *
304
 
 * @param   root     Memory root
305
 
 * @param   MyFlags  Flags for what should be freed:
306
 
 *   @li   MARK_BLOCKS_FREED    Don't free blocks, just mark them free
307
 
 *   @li   KEEP_PREALLOC        If this is not set, then free also the
308
 
 *                              preallocated block
309
 
 */
310
 
void memory::Root::free_root(myf MyFlags)
 
266
 
 
267
/*
 
268
  Deallocate everything used by alloc_root or just move
 
269
  used blocks to free list if called with MY_USED_TO_FREE
 
270
 
 
271
  SYNOPSIS
 
272
    free_root()
 
273
      root              Memory root
 
274
      MyFlags           Flags for what should be freed:
 
275
 
 
276
        MY_MARK_BLOCKS_FREED    Don't free blocks, just mark them free
 
277
        MY_KEEP_PREALLOC        If this is not set, then free also the
 
278
                                preallocated block
 
279
 
 
280
  NOTES
 
281
    One can call this function either with root block initialised with
 
282
    init_alloc_root() or with a zero:ed block.
 
283
    It's also safe to call this multiple times with the same mem_root.
 
284
*/
 
285
 
 
286
void free_root(MEM_ROOT *root, myf MyFlags)
311
287
{
312
 
  memory::internal::UsedMemory *next,*old;
 
288
  register USED_MEM *next,*old;
313
289
 
314
 
  if (MyFlags & memory::MARK_BLOCKS_FREE)
 
290
  if (MyFlags & MY_MARK_BLOCKS_FREE)
315
291
  {
316
 
    this->mark_blocks_free();
 
292
    mark_blocks_free(root);
317
293
    return;
318
294
  }
319
 
  if (!(MyFlags & memory::KEEP_PREALLOC))
320
 
    this->pre_alloc=0;
 
295
  if (!(MyFlags & MY_KEEP_PREALLOC))
 
296
    root->pre_alloc=0;
321
297
 
322
 
  for (next=this->used; next ;)
 
298
  for (next=root->used; next ;)
323
299
  {
324
300
    old=next; next= next->next ;
325
 
    if (old != this->pre_alloc)
326
 
      std::free(old);
 
301
    if (old != root->pre_alloc)
 
302
      free(old);
327
303
  }
328
 
  for (next=this->free ; next ;)
 
304
  for (next=root->free ; next ;)
329
305
  {
330
306
    old=next; next= next->next;
331
 
    if (old != this->pre_alloc)
332
 
      std::free(old);
333
 
  }
334
 
  this->used=this->free=0;
335
 
  if (this->pre_alloc)
336
 
  {
337
 
    this->free=this->pre_alloc;
338
 
    this->free->left=this->pre_alloc->size-ALIGN_SIZE(sizeof(memory::internal::UsedMemory));
339
 
    TRASH_MEM(this->pre_alloc);
340
 
    this->free->next=0;
341
 
  }
342
 
  this->block_num= 4;
343
 
  this->first_block_usage= 0;
344
 
}
345
 
 
346
 
/**
347
 
 * @brief
348
 
 * Duplicate a null-terminated string into memory allocated from within the
349
 
 * specified Root
350
 
 */
351
 
char *memory::Root::strdup_root(const char *str)
352
 
{
353
 
  return strmake_root(str, strlen(str));
354
 
}
355
 
 
356
 
/**
357
 
 * @brief
358
 
 * Copy the (not necessarily null-terminated) string into memory allocated
359
 
 * from within the specified Root
360
 
 *
361
 
 * @details
362
 
 * Note that the string is copied according to the length specified, so
363
 
 * null-termination is ignored. The duplicated string will be null-terminated,
364
 
 * even if the original string wasn't (one additional byte is allocated for
365
 
 * this purpose).
366
 
 */
367
 
char *memory::Root::strmake_root(const char *str, size_t len)
 
307
    if (old != root->pre_alloc)
 
308
      free(old);
 
309
  }
 
310
  root->used=root->free=0;
 
311
  if (root->pre_alloc)
 
312
  {
 
313
    root->free=root->pre_alloc;
 
314
    root->free->left=root->pre_alloc->size-ALIGN_SIZE(sizeof(USED_MEM));
 
315
    TRASH_MEM(root->pre_alloc);
 
316
    root->free->next=0;
 
317
  }
 
318
  root->block_num= 4;
 
319
  root->first_block_usage= 0;
 
320
  return;
 
321
}
 
322
 
 
323
/*
 
324
  Find block that contains an object and set the pre_alloc to it
 
325
*/
 
326
 
 
327
void set_prealloc_root(MEM_ROOT *root, char *ptr)
 
328
{
 
329
  USED_MEM *next;
 
330
  for (next=root->used; next ; next=next->next)
 
331
  {
 
332
    if ((char*) next <= ptr && (char*) next + next->size > ptr)
 
333
    {
 
334
      root->pre_alloc=next;
 
335
      return;
 
336
    }
 
337
  }
 
338
  for (next=root->free ; next ; next=next->next)
 
339
  {
 
340
    if ((char*) next <= ptr && (char*) next + next->size > ptr)
 
341
    {
 
342
      root->pre_alloc=next;
 
343
      return;
 
344
    }
 
345
  }
 
346
}
 
347
 
 
348
 
 
349
char *strdup_root(MEM_ROOT *root, const char *str)
 
350
{
 
351
  return strmake_root(root, str, strlen(str));
 
352
}
 
353
 
 
354
 
 
355
char *strmake_root(MEM_ROOT *root, const char *str, size_t len)
368
356
{
369
357
  char *pos;
370
 
  if ((pos= (char *)alloc_root(len+1)))
 
358
  if ((pos=(char *)alloc_root(root,len+1)))
371
359
  {
372
360
    memcpy(pos,str,len);
373
361
    pos[len]=0;
375
363
  return pos;
376
364
}
377
365
 
378
 
/**
379
 
 * @brief
380
 
 * Duplicate the provided block into memory allocated from within the specified
381
 
 * Root
382
 
 *
383
 
 * @return
384
 
 * non-NULL pointer to a copy of the data if memory could be allocated, otherwise
385
 
 * NULL
386
 
 */
387
 
void *memory::Root::memdup_root(const void *str, size_t len)
 
366
 
 
367
void *memdup_root(MEM_ROOT *root, const void *str, size_t len)
388
368
{
389
369
  void *pos;
390
 
 
391
 
  if ((pos= this->alloc_root(len)))
 
370
  if ((pos=alloc_root(root,len)))
392
371
    memcpy(pos,str,len);
393
 
 
394
372
  return pos;
395
373
}
396
 
 
397
 
} /* namespace drizzled */