MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / init_alloc_root

Function init_alloc_root

mysys/my_alloc.c:46–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44*/
45
46void init_alloc_root(MEM_ROOT *mem_root, size_t block_size,
47 size_t pre_alloc_size __attribute__((unused)))
48{
49 DBUG_ENTER("init_alloc_root");
50 DBUG_PRINT("enter",("root: 0x%lx", (long) mem_root));
51
52 mem_root->free= mem_root->used= mem_root->pre_alloc= 0;
53 mem_root->min_malloc= 32;
54 mem_root->block_size= block_size - ALLOC_ROOT_MIN_BLOCK_SIZE;
55 mem_root->error_handler= 0;
56 mem_root->block_num= 4; /* We shift this with >>2 */
57 mem_root->first_block_usage= 0;
58
59#if !(defined(HAVE_purify) && defined(EXTRA_DEBUG))
60 if (pre_alloc_size)
61 {
62 if ((mem_root->free= mem_root->pre_alloc=
63 (USED_MEM*) my_malloc(pre_alloc_size+ ALIGN_SIZE(sizeof(USED_MEM)),
64 MYF(0))))
65 {
66 mem_root->free->size= pre_alloc_size+ALIGN_SIZE(sizeof(USED_MEM));
67 mem_root->free->left= pre_alloc_size;
68 mem_root->free->next= 0;
69 }
70 }
71#endif
72 DBUG_VOID_RETURN;
73}
74
75/** This is a no-op unless the build is debug or for Valgrind. */
76#define TRASH_MEM(X) TRASH(((char*)(X) + ((X)->size-(X)->left)), (X)->left)

Callers 9

free_old_queryFunction · 0.85
cli_read_rowsFunction · 0.85
init_sql_allocFunction · 0.85
initMethod · 0.85
my_dirFunction · 0.85
my_lib.cFile · 0.85
init_treeFunction · 0.85
my_load_defaultsFunction · 0.85
my_print_default_filesFunction · 0.85

Calls 1

my_mallocFunction · 0.85

Tested by

no test coverage detected