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

Function mem_root_dynamic_array_init

mysys/array.c:420–463  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

418}
419
420int mem_root_dynamic_array_init(MEM_ROOT *current_mem_root,
421 PSI_memory_key psi_key,
422 MEM_ROOT_DYNAMIC_ARRAY *array,
423 size_t element_size, void *init_buffer,
424 size_t init_alloc, size_t alloc_increment,
425 myf my_flags)
426{
427 DBUG_ENTER("init_mem_root_dynamic_array");
428
429 array->elements=0;
430 array->max_element=init_alloc;
431 array->alloc_increment=alloc_increment;
432 array->size_of_element=element_size;
433 array->m_psi_key= psi_key;
434 array->malloc_flags= my_flags;
435 array->mem_root= current_mem_root;
436
437 if ((array->buffer= (uchar*)init_buffer))
438 {
439 array->malloc_flags|= MY_INIT_BUFFER_USED;
440 memset(array->buffer, 0, array->size_of_element*array->max_element);
441 DBUG_RETURN(FALSE);
442 }
443
444 if (!alloc_increment && !(my_flags & MY_BUFFER_NO_RESIZE))
445 {
446 alloc_increment=MY_MAX((8192-MALLOC_OVERHEAD)/element_size,16);
447 if (init_alloc > 8 && alloc_increment > init_alloc * 2)
448 alloc_increment=init_alloc*2;
449 }
450
451 /*
452 Since the dynamic array is usable even if allocation fails here malloc
453 should not throw an error
454 */
455 if (init_alloc &&
456 !(array->buffer= (uchar*) alloc_root(array->mem_root,
457 array->size_of_element*
458 array->max_element)))
459 array->max_element=0;
460 memset(array->buffer, 0, array->size_of_element*array->max_element);
461
462 DBUG_RETURN(FALSE);
463}
464
465void mem_root_dynamic_array_reset(MEM_ROOT_DYNAMIC_ARRAY *array)
466{

Callers 15

json_typeFunction · 0.85
json_get_array_itemFunction · 0.85
json_get_object_keyFunction · 0.85
json_get_object_nkeyFunction · 0.85
initJsonArrayFunction · 0.85
rnd_initMethod · 0.85
init_json_engineMethod · 0.85
setMethod · 0.85
set_pathMethod · 0.85
handle_keywordMethod · 0.85
fix_length_and_decMethod · 0.85
parseMethod · 0.85

Calls 1

alloc_rootFunction · 0.85

Tested by

no test coverage detected