MySQL  8.0.18
Source Code Documentation
mem0mem.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved.
4 
5 This program is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License, version 2.0, as published by the
7 Free Software Foundation.
8 
9 This program is also distributed with certain software (including but not
10 limited to OpenSSL) that is licensed under separate terms, as designated in a
11 particular file or component or in included license documentation. The authors
12 of MySQL hereby grant you an additional permission to link the program and
13 your derivative works with the separately licensed software that they have
14 included with MySQL.
15 
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
19 for more details.
20 
21 You should have received a copy of the GNU General Public License along with
22 this program; if not, write to the Free Software Foundation, Inc.,
23 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 
25 *****************************************************************************/
26 
27 /** @file include/mem0mem.h
28  The memory management
29 
30  Created 6/9/1994 Heikki Tuuri
31  *******************************************************/
32 
33 #ifndef mem0mem_h
34 #define mem0mem_h
35 
36 #include "mach0data.h"
37 #include "univ.i"
38 #include "ut0byte.h"
39 #include "ut0mem.h"
40 #include "ut0rnd.h"
41 
42 #include <limits.h>
43 
44 #include <memory>
45 
46 /* -------------------- MEMORY HEAPS ----------------------------- */
47 
48 /** A block of a memory heap consists of the info structure
49 followed by an area of memory */
51 
52 /** A memory heap is a nonempty linear list of memory blocks */
54 
55 /** Types of allocation for memory heaps: DYNAMIC means allocation from the
56 dynamic memory pool of the C compiler, BUFFER means allocation from the
57 buffer pool; the latter method is used for very big heaps */
58 
59 #define MEM_HEAP_DYNAMIC 0 /* the most common type */
60 #define MEM_HEAP_BUFFER 1
61 #define MEM_HEAP_BTR_SEARCH \
62  2 /* this flag can optionally be \
63  ORed to MEM_HEAP_BUFFER, in which \
64  case heap->free_block is used in \
65  some cases for memory allocations, \
66  and if it's NULL, the memory \
67  allocation functions can return \
68  NULL. */
69 
70 /** Different type of heaps in terms of which data structure is using them */
71 #define MEM_HEAP_FOR_BTR_SEARCH (MEM_HEAP_BTR_SEARCH | MEM_HEAP_BUFFER)
72 #define MEM_HEAP_FOR_PAGE_HASH (MEM_HEAP_DYNAMIC)
73 #define MEM_HEAP_FOR_RECV_SYS (MEM_HEAP_BUFFER)
74 #define MEM_HEAP_FOR_LOCK_HEAP (MEM_HEAP_BUFFER)
75 
76 /** The following start size is used for the first block in the memory heap if
77 the size is not specified, i.e., 0 is given as the parameter in the call of
78 create. The standard size is the maximum (payload) size of the blocks used for
79 allocations of small buffers. */
80 
81 #define MEM_BLOCK_START_SIZE 64
82 #define MEM_BLOCK_STANDARD_SIZE \
83  (UNIV_PAGE_SIZE >= 16384 ? 8000 : MEM_MAX_ALLOC_IN_BUF)
84 
85 /** If a memory heap is allowed to grow into the buffer pool, the following
86 is the maximum size for a single allocated buffer
87 (from UNIV_PAGE_SIZE we subtract MEM_BLOCK_HEADER_SIZE and 2*MEM_NO_MANS_LAND
88 since it's something we always need to put. Since in MEM_SPACE_NEEDED we round
89 n to the next multiple of UNIV_MEM_ALINGMENT, we need to cut from the rest the
90 part that cannot be divided by UNIV_MEM_ALINGMENT): */
91 #define MEM_MAX_ALLOC_IN_BUF \
92  ((UNIV_PAGE_SIZE - MEM_BLOCK_HEADER_SIZE - 2 * MEM_NO_MANS_LAND) & \
93  ~(UNIV_MEM_ALIGNMENT - 1))
94 
95 /* Before and after any allocated object we will put MEM_NO_MANS_LAND bytes of
96 some data (different before and after) which is supposed not to be modified by
97 anyone. This way it would be much easier to determine whether anyone was
98 writing on not his memory, especially that Valgrind can assure there was no
99 reads or writes to this memory. */
100 #ifdef UNIV_DEBUG
101 const int MEM_NO_MANS_LAND = 16;
102 #else
103 const int MEM_NO_MANS_LAND = 0;
104 #endif
105 
106 /* Byte that we would put before allocated object MEM_NO_MANS_LAND times.*/
108 /* Byte that we would put after allocated object MEM_NO_MANS_LAND times.*/
110 
111 /** Space needed when allocating for a user a field of length N.
112 The space is allocated only in multiples of UNIV_MEM_ALIGNMENT. In debug mode
113 contains two areas of no mans lands before and after the buffer requested. */
114 #define MEM_SPACE_NEEDED(N) \
115  ut_calc_align(N + 2 * MEM_NO_MANS_LAND, UNIV_MEM_ALIGNMENT)
116 
117 #ifdef UNIV_DEBUG
118 /** Macro for memory heap creation.
119 @param[in] size Desired start block size. */
120 #define mem_heap_create(size) \
121  mem_heap_create_func((size), __FILE__, __LINE__, MEM_HEAP_DYNAMIC)
122 
123 /** Macro for memory heap creation.
124 @param[in] size Desired start block size.
125 @param[in] type Heap type */
126 #define mem_heap_create_typed(size, type) \
127  mem_heap_create_func((size), __FILE__, __LINE__, (type))
128 
129 #else /* UNIV_DEBUG */
130 /** Macro for memory heap creation.
131 @param[in] size Desired start block size. */
132 #define mem_heap_create(size) mem_heap_create_func((size), MEM_HEAP_DYNAMIC)
133 
134 /** Macro for memory heap creation.
135 @param[in] size Desired start block size.
136 @param[in] type Heap type */
137 #define mem_heap_create_typed(size, type) mem_heap_create_func((size), (type))
138 
139 #endif /* UNIV_DEBUG */
140 
141 /** Creates a memory heap.
142 NOTE: Use the corresponding macros instead of this function.
143 A single user buffer of 'size' will fit in the block.
144 0 creates a default size block.
145 @param[in] size Desired start block size.
146 @param[in] file_name File name where created
147 @param[in] line Line where created
148 @param[in] type Heap type
149 @return own: memory heap, NULL if did not succeed (only possible for
150 MEM_HEAP_BTR_SEARCH type heaps) */
151 UNIV_INLINE
152 mem_heap_t *mem_heap_create_func(ulint size,
153 #ifdef UNIV_DEBUG
154  const char *file_name, ulint line,
155 #endif /* UNIV_DEBUG */
156  ulint type);
157 
158 /** Frees the space occupied by a memory heap.
159 NOTE: Use the corresponding macro instead of this function.
160 @param[in] heap Heap to be freed */
161 UNIV_INLINE
162 void mem_heap_free(mem_heap_t *heap);
163 
164 /** Allocates and zero-fills n bytes of memory from a memory heap.
165 @param[in] heap memory heap
166 @param[in] n number of bytes; if the heap is allowed to grow into
167 the buffer pool, this must be <= MEM_MAX_ALLOC_IN_BUF
168 @return allocated, zero-filled storage */
169 UNIV_INLINE
170 void *mem_heap_zalloc(mem_heap_t *heap, ulint n);
171 
172 /** Allocates n bytes of memory from a memory heap.
173 @param[in] heap memory heap
174 @param[in] n number of bytes; if the heap is allowed to grow into
175 the buffer pool, this must be <= MEM_MAX_ALLOC_IN_BUF
176 @return allocated storage, NULL if did not succeed (only possible for
177 MEM_HEAP_BTR_SEARCH type heaps) */
178 UNIV_INLINE
179 void *mem_heap_alloc(mem_heap_t *heap, ulint n);
180 
181 /** Returns a pointer to the heap top.
182 @param[in] heap memory heap
183 @return pointer to the heap top */
184 UNIV_INLINE
186 
187 /** Frees the space in a memory heap exceeding the pointer given.
188 The pointer must have been acquired from mem_heap_get_heap_top.
189 The first memory block of the heap is not freed.
190 @param[in] heap heap from which to free
191 @param[in] old_top pointer to old top of heap */
192 UNIV_INLINE
193 void mem_heap_free_heap_top(mem_heap_t *heap, byte *old_top);
194 
195 /** Empties a memory heap.
196 The first memory block of the heap is not freed.
197 @param[in] heap heap to empty */
198 UNIV_INLINE
199 void mem_heap_empty(mem_heap_t *heap);
200 
201 /** Returns a pointer to the topmost element in a memory heap.
202 The size of the element must be given.
203 @param[in] heap memory heap
204 @param[in] n size of the topmost element
205 @return pointer to the topmost element */
206 UNIV_INLINE
207 void *mem_heap_get_top(mem_heap_t *heap, ulint n);
208 
209 /** Checks if a given chunk of memory is the topmost element stored in the
210 heap. If this is the case, then calling mem_heap_free_top() would free
211 that element from the heap.
212 @param[in] heap memory heap
213 @param[in] buf presumed topmost element
214 @param[in] buf_sz size of buf in bytes
215 @return true if topmost */
216 UNIV_INLINE
217 bool mem_heap_is_top(mem_heap_t *heap, const void *buf, ulint buf_sz)
218  MY_ATTRIBUTE((warn_unused_result));
219 
220 /** Allocate a new chunk of memory from a memory heap, possibly discarding the
221 topmost element. If the memory chunk specified with (top, top_sz) is the
222 topmost element, then it will be discarded, otherwise it will be left untouched
223 and this function will be equivallent to mem_heap_alloc().
224 @param[in,out] heap memory heap
225 @param[in] top chunk to discard if possible
226 @param[in] top_sz size of top in bytes
227 @param[in] new_sz desired size of the new chunk
228 @return allocated storage, NULL if did not succeed (only possible for
229 MEM_HEAP_BTR_SEARCH type heaps) */
230 UNIV_INLINE
231 void *mem_heap_replace(mem_heap_t *heap, const void *top, ulint top_sz,
232  ulint new_sz);
233 
234 /** Allocate a new chunk of memory from a memory heap, possibly discarding the
235 topmost element and then copy the specified data to it. If the memory chunk
236 specified with (top, top_sz) is the topmost element, then it will be discarded,
237 otherwise it will be left untouched and this function will be equivalent to
238 mem_heap_dup().
239 @param[in,out] heap memory heap
240 @param[in] top chunk to discard if possible
241 @param[in] top_sz size of top in bytes
242 @param[in] data new data to duplicate
243 @param[in] data_sz size of data in bytes
244 @return allocated storage, NULL if did not succeed (only possible for
245 MEM_HEAP_BTR_SEARCH type heaps) */
246 UNIV_INLINE
247 void *mem_heap_dup_replace(mem_heap_t *heap, const void *top, ulint top_sz,
248  const void *data, ulint data_sz);
249 
250 /** Allocate a new chunk of memory from a memory heap, possibly discarding the
251 topmost element and then copy the specified string to it. If the memory chunk
252 specified with (top, top_sz) is the topmost element, then it will be discarded,
253 otherwise it will be left untouched and this function will be equivalent to
254 mem_heap_strdup().
255 @param[in,out] heap memory heap
256 @param[in] top chunk to discard if possible
257 @param[in] top_sz size of top in bytes
258 @param[in] str new data to duplicate
259 @return allocated string, NULL if did not succeed (only possible for
260 MEM_HEAP_BTR_SEARCH type heaps) */
261 UNIV_INLINE
262 char *mem_heap_strdup_replace(mem_heap_t *heap, const void *top, ulint top_sz,
263  const char *str);
264 
265 /** Frees the topmost element in a memory heap.
266 @param[in] heap memory heap
267 @param[in] n size of the topmost element
268 The size of the element must be given. */
269 UNIV_INLINE
270 void mem_heap_free_top(mem_heap_t *heap, ulint n);
271 
272 /** Returns the space in bytes occupied by a memory heap. */
273 UNIV_INLINE
274 ulint mem_heap_get_size(mem_heap_t *heap); /*!< in: heap */
275 
276 /** Duplicates a NUL-terminated string.
277 @param[in] str string to be copied
278 @return own: a copy of the string, must be deallocated with ut_free */
279 UNIV_INLINE
280 char *mem_strdup(const char *str);
281 
282 /** Makes a NUL-terminated copy of a nonterminated string.
283 @param[in] str string to be copied
284 @param[in] len length of str, in bytes
285 @return own: a copy of the string, must be deallocated with ut_free */
286 UNIV_INLINE
287 char *mem_strdupl(const char *str, ulint len);
288 
289 /** Duplicates a NUL-terminated string, allocated from a memory heap.
290 @param[in] heap memory heap where string is allocated
291 @param[in] str string to be copied
292 @return own: a copy of the string */
293 char *mem_heap_strdup(mem_heap_t *heap, const char *str);
294 
295 /** Makes a NUL-terminated copy of a nonterminated string, allocated from a
296 memory heap.
297 @param[in] heap memory heap where string is allocated
298 @param[in] str string to be copied
299 @param[in] len length of str, in bytes
300 @return own: a copy of the string */
301 UNIV_INLINE
302 char *mem_heap_strdupl(mem_heap_t *heap, const char *str, ulint len);
303 
304 /** Concatenate two strings and return the result, using a memory heap.
305  @return own: the result */
306 char *mem_heap_strcat(
307  mem_heap_t *heap, /*!< in: memory heap where string is allocated */
308  const char *s1, /*!< in: string 1 */
309  const char *s2); /*!< in: string 2 */
310 
311 /** Duplicate a block of data, allocated from a memory heap.
312  @return own: a copy of the data */
313 void *mem_heap_dup(
314  mem_heap_t *heap, /*!< in: memory heap where copy is allocated */
315  const void *data, /*!< in: data to be copied */
316  ulint len); /*!< in: length of data, in bytes */
317 
318 /** A simple sprintf replacement that dynamically allocates the space for the
319  formatted string from the given heap. This supports a very limited set of
320  the printf syntax: types 's' and 'u' and length modifier 'l' (which is
321  required for the 'u' type).
322  @return heap-allocated formatted string */
323 char *mem_heap_printf(mem_heap_t *heap, /*!< in: memory heap */
324  const char *format, /*!< in: format string */
325  ...) MY_ATTRIBUTE((format(printf, 2, 3)));
326 
327 /** Checks that an object is a memory heap (or a block of it)
328 @param[in] heap Memory heap to check */
329 UNIV_INLINE
330 void mem_block_validate(const mem_heap_t *heap);
331 
332 #ifdef UNIV_DEBUG
333 /** Validates the contents of a memory heap.
334 Asserts that the memory heap is consistent
335 @param[in] heap Memory heap to validate */
336 void mem_heap_validate(const mem_heap_t *heap);
337 
338 #endif /* UNIV_DEBUG */
339 
340 /*#######################################################################*/
341 
342 /** The info structure stored at the beginning of a heap block */
344  uint64_t magic_n; /* magic number for debugging */
345 #ifdef UNIV_DEBUG
346  char file_name[16]; /* file name where the mem heap was created */
347  ulint line; /*!< line number where the mem heap was created */
348 #endif /* UNIV_DEBUG */
350  base; /* In the first block in the
351 the list this is the base node of the list of blocks;
352 in subsequent blocks this is undefined */
354  list; /* This contains pointers to next
355  and prev in the list. The first block allocated
356  to the heap is also the first block in this list,
357  though it also contains the base node of the list. */
358  ulint len; /*!< physical length of this block in bytes */
359  ulint total_size; /*!< physical length in bytes of all blocks
360  in the heap. This is defined only in the base
361  node and is set to ULINT_UNDEFINED in others. */
362  ulint type; /*!< type of heap: MEM_HEAP_DYNAMIC, or
363  MEM_HEAP_BUF possibly ORed to MEM_HEAP_BTR_SEARCH */
364  ulint free; /*!< offset in bytes of the first free position for
365  user data in the block */
366  ulint start; /*!< the value of the struct field 'free' at the
367  creation of the block */
368  void *free_block;
369  /* if the MEM_HEAP_BTR_SEARCH bit is set in type,
370  and this is the heap root, this can contain an
371  allocated buffer frame, which can be appended as a
372  free block to the heap, if we need more space;
373  otherwise, this is NULL */
374  void *buf_block;
375  /* if this block has been allocated from the buffer
376  pool, this contains the buf_block_t handle;
377  otherwise, this is NULL */
378 };
379 
380 #define MEM_BLOCK_MAGIC_N 0x445566778899AABB
381 #define MEM_FREED_BLOCK_MAGIC_N 0xBBAA998877665544
382 
383 /* Header size for a memory heap block */
384 #define MEM_BLOCK_HEADER_SIZE \
385  ut_calc_align(sizeof(mem_block_info_t), UNIV_MEM_ALIGNMENT)
386 
387 #include "mem0mem.ic"
388 
389 /** A C++ wrapper class to the mem_heap_t routines, so that it can be used
390 as an STL allocator */
391 template <typename T>
393  public:
394  typedef T value_type;
395  typedef size_t size_type;
396  typedef ptrdiff_t difference_type;
397  typedef T *pointer;
398  typedef const T *const_pointer;
399  typedef T &reference;
400  typedef const T &const_reference;
401 
402  mem_heap_allocator(mem_heap_t *heap) : m_heap(heap) {}
403 
404  mem_heap_allocator(const mem_heap_allocator &other) : m_heap(other.m_heap) {
405  // Do nothing
406  }
407 
408  template <typename U>
410  : m_heap(other.m_heap) {
411  // Do nothing
412  }
413 
414  ~mem_heap_allocator() { m_heap = 0; }
415 
416  size_type max_size() const { return (ULONG_MAX / sizeof(T)); }
417 
418  /** This function returns a pointer to the first element of a newly
419  allocated array large enough to contain n objects of type T; only the
420  memory is allocated, and the objects are not constructed. Moreover,
421  an optional pointer argument (that points to an object already
422  allocated by mem_heap_allocator) can be used as a hint to the
423  implementation about where the new memory should be allocated in
424  order to improve locality. */
426  return (reinterpret_cast<pointer>(mem_heap_alloc(m_heap, n * sizeof(T))));
427  }
428 
430 
431  pointer address(reference r) const { return (&r); }
432 
433  const_pointer address(const_reference r) const { return (&r); }
434 
436  new (reinterpret_cast<void *>(p)) T(t);
437  }
438 
439  void destroy(pointer p) { (reinterpret_cast<T *>(p))->~T(); }
440 
441  /** Allocators are required to supply the below template class member
442  which enables the possibility of obtaining a related allocator,
443  parametrized in terms of a different type. For example, given an
444  allocator type IntAllocator for objects of type int, a related
445  allocator type for objects of type long could be obtained using
446  IntAllocator::rebind<long>::other */
447  template <typename U>
448  struct rebind {
450  };
451 
452  /** Get the underlying memory heap object.
453  @return the underlying memory heap object. */
454  mem_heap_t *get_mem_heap() const { return (m_heap); }
455 
456  private:
458  template <typename U>
459  friend class mem_heap_allocator;
460 };
461 
462 template <class T>
464  const mem_heap_allocator<T> &right) {
465  return (left.get_mem_heap() == right.get_mem_heap());
466 }
467 
468 template <class T>
470  const mem_heap_allocator<T> &right) {
471  return (left.get_mem_heap() != right.get_mem_heap());
472 }
473 
474 #endif
UNIV_INLINE void * mem_heap_get_top(mem_heap_t *heap, ulint n)
Returns a pointer to the topmost element in a memory heap.
void * mem_heap_dup(mem_heap_t *heap, const void *data, ulint len)
Duplicate a block of data, allocated from a memory heap.
Definition: memory.cc:56
UNIV_INLINE char * mem_heap_strdup_replace(mem_heap_t *heap, const void *top, ulint top_sz, const char *str)
Allocate a new chunk of memory from a memory heap, possibly discarding the topmost element and then c...
ulint line
line number where the mem heap was created
Definition: mem0mem.h:347
const int MEM_NO_MANS_LAND
Definition: mem0mem.h:101
void * free_block
Definition: mem0mem.h:368
mem_heap_t * get_mem_heap() const
Get the underlying memory heap object.
Definition: mem0mem.h:454
base
Definition: mem0mem.h:350
UNIV_INLINE ulint mem_heap_get_size(mem_heap_t *heap)
Returns the space in bytes occupied by a memory heap.
mem_heap_allocator(const mem_heap_allocator &other)
Definition: mem0mem.h:404
const byte MEM_NO_MANS_LAND_AFTER_BYTE
Definition: mem0mem.h:109
char * mem_heap_strdup(mem_heap_t *heap, const char *str)
Duplicates a NUL-terminated string, allocated from a memory heap.
Definition: memory.cc:50
ulint start
the value of the struct field &#39;free&#39; at the creation of the block
Definition: mem0mem.h:366
ptrdiff_t difference_type
Definition: mem0mem.h:396
list
Definition: mem0mem.h:354
char file_name[16]
Definition: mem0mem.h:346
T & reference
Definition: mem0mem.h:399
UNIV_INLINE void mem_heap_free_heap_top(mem_heap_t *heap, byte *old_top)
Frees the space in a memory heap exceeding the pointer given.
size_type max_size() const
Definition: mem0mem.h:416
void * buf_block
Definition: mem0mem.h:374
The info structure stored at the beginning of a heap block.
Definition: mem0mem.h:343
void deallocate(pointer p, size_type n)
Definition: mem0mem.h:429
mem_heap_allocator< U > other
Definition: mem0mem.h:449
const byte MEM_NO_MANS_LAND_BEFORE_BYTE
Definition: mem0mem.h:107
~mem_heap_allocator()
Definition: mem0mem.h:414
ulint type
type of heap: MEM_HEAP_DYNAMIC, or MEM_HEAP_BUF possibly ORed to MEM_HEAP_BTR_SEARCH ...
Definition: mem0mem.h:362
size_t size_type
Definition: mem0mem.h:395
void destroy(pointer p)
Definition: mem0mem.h:439
Memory primitives.
const T * const_pointer
Definition: mem0mem.h:398
UNIV_INLINE char * mem_heap_strdupl(mem_heap_t *heap, const char *str, ulint len)
Makes a NUL-terminated copy of a nonterminated string, allocated from a memory heap.
char * mem_heap_strcat(mem_heap_t *heap, const char *s1, const char *s2)
Concatenate two strings and return the result, using a memory heap.
Definition: memory.cc:66
Utilities for converting data from the database file to the machine format.
UNIV_INLINE void mem_heap_free_top(mem_heap_t *heap, ulint n)
Frees the topmost element in a memory heap.
UNIV_INLINE void * mem_heap_dup_replace(mem_heap_t *heap, const void *top, ulint top_sz, const void *data, ulint data_sz)
Allocate a new chunk of memory from a memory heap, possibly discarding the topmost element and then c...
mem_block_t mem_heap_t
A memory heap is a nonempty linear list of memory blocks.
Definition: mem0mem.h:53
pointer address(reference r) const
Definition: mem0mem.h:431
UNIV_INLINE void * mem_heap_replace(mem_heap_t *heap, const void *top, ulint top_sz, ulint new_sz)
Allocate a new chunk of memory from a memory heap, possibly discarding the topmost element...
Utilities for byte operations.
UNIV_INLINE void * mem_heap_alloc(mem_heap_t *heap, ulint n)
Allocates n bytes of memory from a memory heap.
UNIV_INLINE void * mem_heap_zalloc(mem_heap_t *heap, ulint n)
Allocates and zero-fills n bytes of memory from a memory heap.
ulint len
physical length of this block in bytes
Definition: mem0mem.h:358
Allocators are required to supply the below template class member which enables the possibility of ob...
Definition: mem0mem.h:448
int n
Definition: xcom_base.c:425
UNIV_INLINE void mem_heap_empty(mem_heap_t *heap)
Empties a memory heap.
mem_heap_allocator(const mem_heap_allocator< U > &other)
Definition: mem0mem.h:409
bool operator==(const mem_heap_allocator< T > &left, const mem_heap_allocator< T > &right)
Definition: mem0mem.h:463
A C++ wrapper class to the mem_heap_t routines, so that it can be used as an STL allocator.
Definition: mem0mem.h:392
uint64_t magic_n
Definition: mem0mem.h:344
const mysql_service_registry_t * r
Definition: pfs_example_plugin_employee.cc:85
#define UT_LIST_BASE_NODE_T(TYPE)
Definition: innodb_utility.h:47
UNIV_INLINE bool mem_heap_is_top(mem_heap_t *heap, const void *buf, ulint buf_sz)
Checks if a given chunk of memory is the topmost element stored in the heap.
ulint free
offset in bytes of the first free position for user data in the block
Definition: mem0mem.h:364
int type
Definition: http_common.h:411
UNIV_INLINE char * mem_strdupl(const char *str, ulint len)
Makes a NUL-terminated copy of a nonterminated string.
UNIV_INLINE char * mem_strdup(const char *str)
Duplicates a NUL-terminated string.
UNIV_INLINE void mem_heap_free(mem_heap_t *heap)
Frees the space occupied by a memory heap.
mem_heap_allocator(mem_heap_t *heap)
Definition: mem0mem.h:402
T * pointer
Definition: mem0mem.h:397
ulint total_size
physical length in bytes of all blocks in the heap.
Definition: mem0mem.h:359
void mem_heap_validate(const mem_heap_t *heap)
Validates the contents of a memory heap.
Definition: memory.cc:221
Random numbers and hashing.
bool operator!=(const mem_heap_allocator< T > &left, const mem_heap_allocator< T > &right)
Definition: mem0mem.h:469
const char * p
Definition: ctype-mb.cc:1232
UNIV_INLINE byte * mem_heap_get_heap_top(mem_heap_t *heap)
Returns a pointer to the heap top.
void construct(pointer p, const_reference t)
Definition: mem0mem.h:435
char * mem_heap_printf(mem_heap_t *heap, const char *format,...)
A simple sprintf replacement that dynamically allocates the space for the formatted string from the g...
Definition: memory.cc:194
UNIV_INLINE mem_heap_t * mem_heap_create_func(ulint size, const char *file_name, ulint line, ulint type)
Creates a memory heap.
unsigned char byte
Blob class.
Definition: common.h:159
mem_heap_t * m_heap
Definition: mem0mem.h:457
pointer allocate(size_type n, const_pointer hint=0)
This function returns a pointer to the first element of a newly allocated array large enough to conta...
Definition: mem0mem.h:425
#define UT_LIST_NODE_T(TYPE)
Definition: innodb_utility.h:40
const T & const_reference
Definition: mem0mem.h:400
UNIV_INLINE void mem_block_validate(const mem_heap_t *heap)
Checks that an object is a memory heap (or a block of it)
const_pointer address(const_reference r) const
Definition: mem0mem.h:433
T value_type
Definition: mem0mem.h:394