93 #ifdef MEM_PERIODIC_CHECK
95 ibool mem_block_list_inited;
111 return(static_cast<char*>(
mem_heap_dup(heap, str, strlen(str) + 1)));
140 ulint s1_len = strlen(s1);
141 ulint s2_len = strlen(s2);
143 s =
static_cast<char*
>(
mem_heap_alloc(heap, s1_len + s2_len + 1));
145 memcpy(s, s1, s1_len);
146 memcpy(s + s1_len, s2, s2_len);
148 s[s1_len + s2_len] =
'\0';
171 ibool is_long = FALSE;
176 if (*format++ !=
'%') {
182 *buf++ = *(format - 1);
188 if (*format ==
'l') {
197 char* s = va_arg(ap,
char*);
206 memcpy(buf, s, plen);
222 val = va_arg(ap,
unsigned long);
224 plen = sprintf(tmp,
"%lu", val);
228 memcpy(buf, tmp, plen);
283 va_start(ap, format);
284 len = mem_heap_printf_low(NULL, format, ap);
289 va_start(ap, format);
290 mem_heap_printf_low(str, format, ap);
309 const char* file_name,
312 #ifndef UNIV_HOTBACKUP
318 ut_ad((type == MEM_HEAP_DYNAMIC) || (type == MEM_HEAP_BUFFER)
319 || (type == MEM_HEAP_BUFFER + MEM_HEAP_BTR_SEARCH));
321 if (heap && heap->magic_n != MEM_BLOCK_MAGIC_N) {
326 len = MEM_BLOCK_HEADER_SIZE + MEM_SPACE_NEEDED(n);
328 #ifndef UNIV_HOTBACKUP
329 if (type == MEM_HEAP_DYNAMIC || len < UNIV_PAGE_SIZE / 2) {
331 ut_ad(type == MEM_HEAP_DYNAMIC || n <= MEM_MAX_ALLOC_IN_BUF);
336 len = UNIV_PAGE_SIZE;
338 if ((type & MEM_HEAP_BTR_SEARCH) &&
heap) {
343 buf_block =
static_cast<buf_block_t*
>(heap->free_block);
344 heap->free_block = NULL;
346 if (UNIV_UNLIKELY(!buf_block)) {
359 " InnoDB: Unable to allocate memory of size %lu.\n",
362 block->buf_block = buf_block;
363 block->free_block = NULL;
365 len = MEM_BLOCK_HEADER_SIZE + MEM_SPACE_NEEDED(n);
370 block->magic_n = MEM_BLOCK_MAGIC_N;
371 ut_strlcpy_rev(block->file_name, file_name,
sizeof(block->file_name));
374 #ifdef MEM_PERIODIC_CHECK
377 if (!mem_block_list_inited) {
378 mem_block_list_inited = TRUE;
386 mem_block_set_len(block, len);
387 mem_block_set_type(block, type);
388 mem_block_set_free(block, MEM_BLOCK_HEADER_SIZE);
389 mem_block_set_start(block, MEM_BLOCK_HEADER_SIZE);
391 if (UNIV_UNLIKELY(heap == NULL)) {
405 ut_ad((ulint)MEM_BLOCK_HEADER_SIZE < len);
425 ut_ad(mem_heap_check(heap));
433 new_size = 2 * mem_block_get_len(block);
435 if (heap->
type != MEM_HEAP_DYNAMIC) {
437 ut_a(n <= MEM_MAX_ALLOC_IN_BUF);
439 if (new_size > MEM_MAX_ALLOC_IN_BUF) {
440 new_size = MEM_MAX_ALLOC_IN_BUF;
442 }
else if (new_size > MEM_BLOCK_STANDARD_SIZE) {
444 new_size = MEM_BLOCK_STANDARD_SIZE;
452 heap->file_name, heap->
line);
453 if (new_block == NULL) {
476 #ifndef UNIV_HOTBACKUP
479 buf_block =
static_cast<buf_block_t*
>(block->buf_block);
482 if (block->magic_n != MEM_BLOCK_MAGIC_N) {
488 #ifdef MEM_PERIODIC_CHECK
501 block->magic_n = MEM_FREED_BLOCK_MAGIC_N;
503 #ifndef UNIV_HOTBACKUP
504 if (!srv_use_sys_malloc) {
505 #ifdef UNIV_MEM_DEBUG
509 mem_erase_buf((byte*) block, len);
511 UNIV_MEM_ASSERT_AND_FREE(block, len);
515 if (type == MEM_HEAP_DYNAMIC || len < UNIV_PAGE_SIZE / 2) {
520 ut_ad(type & MEM_HEAP_BUFFER);
525 #ifdef UNIV_MEM_DEBUG
529 mem_erase_buf((byte*) block, len);
531 UNIV_MEM_ASSERT_AND_FREE(block, len);
537 #ifndef UNIV_HOTBACKUP
546 if (UNIV_LIKELY_NULL(heap->free_block)) {
550 heap->free_block = NULL;
555 #ifdef MEM_PERIODIC_CHECK
561 mem_validate_all_blocks(
void)
571 if (block->magic_n != MEM_BLOCK_MAGIC_N) {