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

Function allocate_dynamic

mysys/array.c:270–304  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

268*/
269
270my_bool allocate_dynamic(DYNAMIC_ARRAY *array, size_t max_elements)
271{
272 DBUG_ENTER("allocate_dynamic");
273
274 if (max_elements >= array->max_element)
275 {
276 size_t size;
277 uchar *new_ptr;
278 size= (max_elements + array->alloc_increment)/array->alloc_increment;
279 size*= array->alloc_increment;
280 if (array->malloc_flags & MY_INIT_BUFFER_USED)
281 {
282 /*
283 In this scenario, the buffer is statically preallocated,
284 so we have to create an all-new malloc since we overflowed
285 */
286 if (!(new_ptr= (uchar *) my_malloc(array->m_psi_key, size *
287 array->size_of_element,
288 MYF(array->malloc_flags | MY_WME))))
289 DBUG_RETURN(TRUE);
290 memcpy(new_ptr, array->buffer,
291 array->elements * array->size_of_element);
292 array->malloc_flags&= ~MY_INIT_BUFFER_USED;
293 }
294 else if (!(new_ptr= (uchar*) my_realloc(array->m_psi_key,
295 array->buffer,size *
296 array->size_of_element,
297 MYF(MY_WME | MY_ALLOW_ZERO_PTR |
298 array->malloc_flags))))
299 DBUG_RETURN(TRUE);
300 array->buffer= new_ptr;
301 array->max_element= size;
302 }
303 DBUG_RETURN(FALSE);
304}
305
306
307/*

Callers 10

load_fromMethod · 0.85
reserveMethod · 0.85
reoptimizeMethod · 0.85
set_dynamicFunction · 0.85
translog_create_new_fileFunction · 0.85
translog_init_with_tableFunction · 0.85
find_tailFunction · 0.85
find_blobFunction · 0.85
extent_to_bitmap_blocksFunction · 0.85

Calls 2

my_mallocFunction · 0.85
my_reallocFunction · 0.85

Tested by

no test coverage detected