MCPcopy Create free account
hub / github.com/MariaDB/server / init_dynamic_array2

Function init_dynamic_array2

mysys/array.c:44–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42*/
43
44my_bool init_dynamic_array2(PSI_memory_key psi_key, DYNAMIC_ARRAY *array,
45 size_t element_size, void *init_buffer,
46 size_t init_alloc, size_t alloc_increment,
47 myf my_flags)
48{
49 DBUG_ENTER("init_dynamic_array2");
50 if (!alloc_increment)
51 {
52 alloc_increment=MY_MAX((8192-MALLOC_OVERHEAD)/element_size,16);
53 if (init_alloc > 8 && alloc_increment > init_alloc * 2)
54 alloc_increment=init_alloc*2;
55 }
56 array->elements=0;
57 array->max_element=init_alloc;
58 array->alloc_increment=alloc_increment;
59 array->size_of_element=element_size;
60 array->m_psi_key= psi_key;
61 array->malloc_flags= my_flags;
62 DBUG_ASSERT((my_flags & MY_INIT_BUFFER_USED) == 0);
63 if ((array->buffer= init_buffer))
64 {
65 array->malloc_flags|= MY_INIT_BUFFER_USED;
66 DBUG_RETURN(FALSE);
67 }
68 /*
69 Since the dynamic array is usable even if allocation fails here malloc
70 should not throw an error
71 */
72 if (init_alloc &&
73 !(array->buffer= (uchar*) my_malloc(psi_key, element_size*init_alloc,
74 MYF(my_flags))))
75 array->max_element=0;
76 DBUG_RETURN(FALSE);
77}
78
79/*
80 Insert element at the end of array. Allocate memory if needed.

Callers 8

findMethod · 0.85
LEXMethod · 0.85
allocMethod · 0.85
Dynamic_arrayMethod · 0.85
initMethod · 0.85
my_hash_init2Function · 0.85
generator_initFunction · 0.85
process_defaultsFunction · 0.85

Calls 1

my_mallocFunction · 0.85

Tested by

no test coverage detected