Bug#13418934 REMOVE HAVE_PURIFY DEPENDENCES FROM INNODB
InnoDB: Remove HAVE_purify, UNIV_INIT_MEM_TO_ZERO, UNIV_SET_MEM_TO_ZERO. The compile-time setting HAVE_purify can mask potential bugs. It is being set in PB2 Valgrind runs. We should simply get rid of it, and replace it with UNIV_MEM_INVALID() to declare uninitialized memory as such in Valgrind-instrumented binaries. os_mem_alloc_large(), ut_malloc_low(): Remove the parameter set_to_zero. ut_malloc(): Define as a macro that invokes ut_malloc_low(). buf_pool_init(): Never initialize the buffer pool frames. All pages must be initialized before flushing them to disk. mem_heap_alloc(): Never initialize the allocated memory block. os_mem_alloc_nocache(), ut_test_malloc(): Unused function, remove. rb:813 approved by Jimmy Yang
This commit is contained in:
parent
5e6ff79ac2
commit
a290a84403
@ -634,7 +634,7 @@ buf_pool_init(
|
|||||||
/*----------------------------------------*/
|
/*----------------------------------------*/
|
||||||
} else {
|
} else {
|
||||||
buf_pool->frame_mem = os_mem_alloc_large(
|
buf_pool->frame_mem = os_mem_alloc_large(
|
||||||
UNIV_PAGE_SIZE * (n_frames + 1), TRUE, FALSE);
|
UNIV_PAGE_SIZE * (n_frames + 1), FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf_pool->frame_mem == NULL) {
|
if (buf_pool->frame_mem == NULL) {
|
||||||
@ -756,12 +756,8 @@ buf_pool_init(
|
|||||||
block = buf_pool_get_nth_block(buf_pool, i);
|
block = buf_pool_get_nth_block(buf_pool, i);
|
||||||
|
|
||||||
if (block->frame) {
|
if (block->frame) {
|
||||||
/* Wipe contents of frame to eliminate a Purify
|
UNIV_MEM_INVALID(block->frame, UNIV_PAGE_SIZE);
|
||||||
warning */
|
|
||||||
|
|
||||||
#ifdef HAVE_purify
|
|
||||||
memset(block->frame, '\0', UNIV_PAGE_SIZE);
|
|
||||||
#endif
|
|
||||||
if (srv_use_awe) {
|
if (srv_use_awe) {
|
||||||
/* Add to the list of blocks mapped to
|
/* Add to the list of blocks mapped to
|
||||||
frames */
|
frames */
|
||||||
|
@ -194,10 +194,6 @@ mem_heap_alloc(
|
|||||||
caller */
|
caller */
|
||||||
buf = (byte*)buf + MEM_FIELD_HEADER_SIZE;
|
buf = (byte*)buf + MEM_FIELD_HEADER_SIZE;
|
||||||
|
|
||||||
#endif
|
|
||||||
#ifdef UNIV_SET_MEM_TO_ZERO
|
|
||||||
UNIV_MEM_ALLOC(buf, n);
|
|
||||||
memset(buf, '\0', n);
|
|
||||||
#endif
|
#endif
|
||||||
UNIV_MEM_ALLOC(buf, n);
|
UNIV_MEM_ALLOC(buf, n);
|
||||||
return(buf);
|
return(buf);
|
||||||
|
@ -104,14 +104,6 @@ ulint
|
|||||||
os_proc_get_number(void);
|
os_proc_get_number(void);
|
||||||
/*====================*/
|
/*====================*/
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
Allocates non-cacheable memory. */
|
|
||||||
|
|
||||||
void*
|
|
||||||
os_mem_alloc_nocache(
|
|
||||||
/*=================*/
|
|
||||||
/* out: allocated memory */
|
|
||||||
ulint n); /* in: number of bytes */
|
|
||||||
/********************************************************************
|
|
||||||
Allocates large pages memory. */
|
Allocates large pages memory. */
|
||||||
|
|
||||||
void*
|
void*
|
||||||
@ -119,9 +111,6 @@ os_mem_alloc_large(
|
|||||||
/*===============*/
|
/*===============*/
|
||||||
/* out: allocated memory */
|
/* out: allocated memory */
|
||||||
ulint n, /* in: number of bytes */
|
ulint n, /* in: number of bytes */
|
||||||
ibool set_to_zero, /* in: TRUE if allocated memory
|
|
||||||
should be set to zero if
|
|
||||||
UNIV_SET_MEM_TO_ZERO is defined */
|
|
||||||
ibool assert_on_error);/* in: if TRUE, we crash mysqld if
|
ibool assert_on_error);/* in: if TRUE, we crash mysqld if
|
||||||
the memory cannot be allocated */
|
the memory cannot be allocated */
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
|
@ -72,14 +72,6 @@ Microsoft Visual C++ */
|
|||||||
/* DEBUG VERSION CONTROL
|
/* DEBUG VERSION CONTROL
|
||||||
===================== */
|
===================== */
|
||||||
|
|
||||||
/* The following flag will make InnoDB to initialize
|
|
||||||
all memory it allocates to zero. It hides Purify
|
|
||||||
warnings about reading unallocated memory unless
|
|
||||||
memory is read outside the allocated blocks. */
|
|
||||||
/*
|
|
||||||
#define UNIV_INIT_MEM_TO_ZERO
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Make a non-inline debug version */
|
/* Make a non-inline debug version */
|
||||||
|
|
||||||
#if defined HAVE_VALGRIND
|
#if defined HAVE_VALGRIND
|
||||||
@ -112,15 +104,6 @@ operations (very slow); also UNIV_DEBUG must be defined */
|
|||||||
#define UNIV_BTR_DEBUG /* check B-tree links */
|
#define UNIV_BTR_DEBUG /* check B-tree links */
|
||||||
#define UNIV_LIGHT_MEM_DEBUG /* light memory debugging */
|
#define UNIV_LIGHT_MEM_DEBUG /* light memory debugging */
|
||||||
|
|
||||||
#ifdef HAVE_purify
|
|
||||||
/* The following sets all new allocated memory to zero before use:
|
|
||||||
this can be used to eliminate unnecessary Purify warnings, but note that
|
|
||||||
it also masks many bugs Purify could detect. For detailed Purify analysis it
|
|
||||||
is best to remove the define below and look through the warnings one
|
|
||||||
by one. */
|
|
||||||
#define UNIV_SET_MEM_TO_ZERO
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#define UNIV_SQL_DEBUG
|
#define UNIV_SQL_DEBUG
|
||||||
#define UNIV_LOG_DEBUG
|
#define UNIV_LOG_DEBUG
|
||||||
|
@ -30,38 +30,18 @@ ut_memcmp(const void* str1, const void* str2, ulint n);
|
|||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is
|
Allocates memory. */
|
||||||
defined and set_to_zero is TRUE. */
|
|
||||||
|
|
||||||
void*
|
void*
|
||||||
ut_malloc_low(
|
ut_malloc_low(
|
||||||
/*==========*/
|
/*==========*/
|
||||||
/* out, own: allocated memory */
|
/* out, own: allocated memory */
|
||||||
ulint n, /* in: number of bytes to allocate */
|
ulint n, /* in: number of bytes to allocate */
|
||||||
ibool set_to_zero, /* in: TRUE if allocated memory
|
|
||||||
should be set to zero if
|
|
||||||
UNIV_SET_MEM_TO_ZERO is defined */
|
|
||||||
ibool assert_on_error); /* in: if TRUE, we crash mysqld if
|
ibool assert_on_error); /* in: if TRUE, we crash mysqld if
|
||||||
the memory cannot be allocated */
|
the memory cannot be allocated */
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is
|
Allocates memory. */
|
||||||
defined. */
|
#define ut_malloc(n) ut_malloc_low(n, TRUE)
|
||||||
|
|
||||||
void*
|
|
||||||
ut_malloc(
|
|
||||||
/*======*/
|
|
||||||
/* out, own: allocated memory */
|
|
||||||
ulint n); /* in: number of bytes to allocate */
|
|
||||||
/**************************************************************************
|
|
||||||
Tests if malloc of n bytes would succeed. ut_malloc() asserts if memory runs
|
|
||||||
out. It cannot be used if we want to return an error message. Prints to
|
|
||||||
stderr a message if fails. */
|
|
||||||
|
|
||||||
ibool
|
|
||||||
ut_test_malloc(
|
|
||||||
/*===========*/
|
|
||||||
/* out: TRUE if succeeded */
|
|
||||||
ulint n); /* in: try to allocate this many bytes */
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
Frees a memory block allocated with ut_malloc. */
|
Frees a memory block allocated with ut_malloc. */
|
||||||
|
|
||||||
|
@ -196,11 +196,7 @@ mem_pool_create(
|
|||||||
|
|
||||||
pool = ut_malloc(sizeof(mem_pool_t));
|
pool = ut_malloc(sizeof(mem_pool_t));
|
||||||
|
|
||||||
/* We do not set the memory to zero (FALSE) in the pool,
|
pool->buf = ut_malloc_low(size, TRUE);
|
||||||
but only when allocated at a higher level in mem0mem.c.
|
|
||||||
This is to avoid masking useful Purify warnings. */
|
|
||||||
|
|
||||||
pool->buf = ut_malloc_low(size, FALSE, TRUE);
|
|
||||||
pool->size = size;
|
pool->size = size;
|
||||||
|
|
||||||
mutex_create(&pool->mutex, SYNC_MEM_POOL);
|
mutex_create(&pool->mutex, SYNC_MEM_POOL);
|
||||||
|
@ -531,28 +531,6 @@ os_proc_get_number(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************
|
|
||||||
Allocates non-cacheable memory. */
|
|
||||||
|
|
||||||
void*
|
|
||||||
os_mem_alloc_nocache(
|
|
||||||
/*=================*/
|
|
||||||
/* out: allocated memory */
|
|
||||||
ulint n) /* in: number of bytes */
|
|
||||||
{
|
|
||||||
#ifdef __WIN__
|
|
||||||
void* ptr;
|
|
||||||
|
|
||||||
ptr = VirtualAlloc(NULL, n, MEM_COMMIT,
|
|
||||||
PAGE_READWRITE | PAGE_NOCACHE);
|
|
||||||
ut_a(ptr);
|
|
||||||
|
|
||||||
return(ptr);
|
|
||||||
#else
|
|
||||||
return(ut_malloc(n));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
Allocates large pages memory. */
|
Allocates large pages memory. */
|
||||||
|
|
||||||
@ -561,9 +539,6 @@ os_mem_alloc_large(
|
|||||||
/*===============*/
|
/*===============*/
|
||||||
/* out: allocated memory */
|
/* out: allocated memory */
|
||||||
ulint n, /* in: number of bytes */
|
ulint n, /* in: number of bytes */
|
||||||
ibool set_to_zero, /* in: TRUE if allocated memory
|
|
||||||
should be set to zero if
|
|
||||||
UNIV_SET_MEM_TO_ZERO is defined */
|
|
||||||
ibool assert_on_error)/* in: if TRUE, we crash mysqld if
|
ibool assert_on_error)/* in: if TRUE, we crash mysqld if
|
||||||
the memory cannot be allocated */
|
the memory cannot be allocated */
|
||||||
{
|
{
|
||||||
@ -602,12 +577,6 @@ os_mem_alloc_large(
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (ptr) {
|
if (ptr) {
|
||||||
if (set_to_zero) {
|
|
||||||
#ifdef UNIV_SET_MEM_TO_ZERO
|
|
||||||
memset(ptr, '\0', size);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
return(ptr);
|
return(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -616,7 +585,7 @@ os_mem_alloc_large(
|
|||||||
skip:
|
skip:
|
||||||
#endif /* HAVE_LARGE_PAGES */
|
#endif /* HAVE_LARGE_PAGES */
|
||||||
|
|
||||||
return(ut_malloc_low(n, set_to_zero, assert_on_error));
|
return(ut_malloc_low(n, assert_on_error));
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
|
@ -54,17 +54,13 @@ ut_mem_block_list_init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is
|
Allocates memory. */
|
||||||
defined and set_to_zero is TRUE. */
|
|
||||||
|
|
||||||
void*
|
void*
|
||||||
ut_malloc_low(
|
ut_malloc_low(
|
||||||
/*==========*/
|
/*==========*/
|
||||||
/* out, own: allocated memory */
|
/* out, own: allocated memory */
|
||||||
ulint n, /* in: number of bytes to allocate */
|
ulint n, /* in: number of bytes to allocate */
|
||||||
ibool set_to_zero, /* in: TRUE if allocated memory should be
|
|
||||||
set to zero if UNIV_SET_MEM_TO_ZERO is
|
|
||||||
defined */
|
|
||||||
ibool assert_on_error)/* in: if TRUE, we crash mysqld if the
|
ibool assert_on_error)/* in: if TRUE, we crash mysqld if the
|
||||||
memory cannot be allocated */
|
memory cannot be allocated */
|
||||||
{
|
{
|
||||||
@ -156,12 +152,6 @@ retry:
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (set_to_zero) {
|
|
||||||
#ifdef UNIV_SET_MEM_TO_ZERO
|
|
||||||
memset(ret, '\0', n + sizeof(ut_mem_block_t));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
UNIV_MEM_ALLOC(ret, n + sizeof(ut_mem_block_t));
|
UNIV_MEM_ALLOC(ret, n + sizeof(ut_mem_block_t));
|
||||||
|
|
||||||
((ut_mem_block_t*)ret)->size = n + sizeof(ut_mem_block_t);
|
((ut_mem_block_t*)ret)->size = n + sizeof(ut_mem_block_t);
|
||||||
@ -176,59 +166,6 @@ retry:
|
|||||||
return((void*)((byte*)ret + sizeof(ut_mem_block_t)));
|
return((void*)((byte*)ret + sizeof(ut_mem_block_t)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is
|
|
||||||
defined. */
|
|
||||||
|
|
||||||
void*
|
|
||||||
ut_malloc(
|
|
||||||
/*======*/
|
|
||||||
/* out, own: allocated memory */
|
|
||||||
ulint n) /* in: number of bytes to allocate */
|
|
||||||
{
|
|
||||||
return(ut_malloc_low(n, TRUE, TRUE));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
Tests if malloc of n bytes would succeed. ut_malloc() asserts if memory runs
|
|
||||||
out. It cannot be used if we want to return an error message. Prints to
|
|
||||||
stderr a message if fails. */
|
|
||||||
|
|
||||||
ibool
|
|
||||||
ut_test_malloc(
|
|
||||||
/*===========*/
|
|
||||||
/* out: TRUE if succeeded */
|
|
||||||
ulint n) /* in: try to allocate this many bytes */
|
|
||||||
{
|
|
||||||
void* ret;
|
|
||||||
|
|
||||||
ret = malloc(n);
|
|
||||||
|
|
||||||
if (ret == NULL) {
|
|
||||||
ut_print_timestamp(stderr);
|
|
||||||
fprintf(stderr,
|
|
||||||
" InnoDB: Error: cannot allocate"
|
|
||||||
" %lu bytes of memory for\n"
|
|
||||||
"InnoDB: a BLOB with malloc! Total allocated memory\n"
|
|
||||||
"InnoDB: by InnoDB %lu bytes."
|
|
||||||
" Operating system errno: %d\n"
|
|
||||||
"InnoDB: Check if you should increase"
|
|
||||||
" the swap file or\n"
|
|
||||||
"InnoDB: ulimits of your operating system.\n"
|
|
||||||
"InnoDB: On FreeBSD check you have"
|
|
||||||
" compiled the OS with\n"
|
|
||||||
"InnoDB: a big enough maximum process size.\n",
|
|
||||||
(ulong) n,
|
|
||||||
(ulong) ut_total_allocated_memory,
|
|
||||||
(int) errno);
|
|
||||||
return(FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
free(ret);
|
|
||||||
|
|
||||||
return(TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
Frees a memory block allocated with ut_malloc. */
|
Frees a memory block allocated with ut_malloc. */
|
||||||
|
|
||||||
|
@ -750,11 +750,8 @@ buf_chunk_init(
|
|||||||
for (i = chunk->size; i--; ) {
|
for (i = chunk->size; i--; ) {
|
||||||
|
|
||||||
buf_block_init(block, frame);
|
buf_block_init(block, frame);
|
||||||
|
UNIV_MEM_INVALID(block->frame, UNIV_PAGE_SIZE);
|
||||||
|
|
||||||
#ifdef HAVE_purify
|
|
||||||
/* Wipe contents of frame to eliminate a Purify warning */
|
|
||||||
memset(block->frame, '\0', UNIV_PAGE_SIZE);
|
|
||||||
#endif
|
|
||||||
/* Add the block to the free list */
|
/* Add the block to the free list */
|
||||||
UT_LIST_ADD_LAST(list, buf_pool->free, (&block->page));
|
UT_LIST_ADD_LAST(list, buf_pool->free, (&block->page));
|
||||||
ut_d(block->page.in_free_list = TRUE);
|
ut_d(block->page.in_free_list = TRUE);
|
||||||
|
@ -208,10 +208,6 @@ mem_heap_alloc(
|
|||||||
caller */
|
caller */
|
||||||
buf = (byte*)buf + MEM_FIELD_HEADER_SIZE;
|
buf = (byte*)buf + MEM_FIELD_HEADER_SIZE;
|
||||||
|
|
||||||
#endif
|
|
||||||
#ifdef UNIV_SET_MEM_TO_ZERO
|
|
||||||
UNIV_MEM_ALLOC(buf, n);
|
|
||||||
memset(buf, '\0', n);
|
|
||||||
#endif
|
#endif
|
||||||
UNIV_MEM_ALLOC(buf, n);
|
UNIV_MEM_ALLOC(buf, n);
|
||||||
return(buf);
|
return(buf);
|
||||||
|
@ -146,14 +146,6 @@ Sun Studio */
|
|||||||
/* DEBUG VERSION CONTROL
|
/* DEBUG VERSION CONTROL
|
||||||
===================== */
|
===================== */
|
||||||
|
|
||||||
/* The following flag will make InnoDB to initialize
|
|
||||||
all memory it allocates to zero. It hides Purify
|
|
||||||
warnings about reading unallocated memory unless
|
|
||||||
memory is read outside the allocated blocks. */
|
|
||||||
/*
|
|
||||||
#define UNIV_INIT_MEM_TO_ZERO
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* When this macro is defined then additional test functions will be
|
/* When this macro is defined then additional test functions will be
|
||||||
compiled. These functions live at the end of each relevant source file
|
compiled. These functions live at the end of each relevant source file
|
||||||
and have "test_" prefix. These functions are not called from anywhere in
|
and have "test_" prefix. These functions are not called from anywhere in
|
||||||
@ -218,15 +210,6 @@ operations (very slow); also UNIV_DEBUG must be defined */
|
|||||||
#define UNIV_BTR_DEBUG /* check B-tree links */
|
#define UNIV_BTR_DEBUG /* check B-tree links */
|
||||||
#define UNIV_LIGHT_MEM_DEBUG /* light memory debugging */
|
#define UNIV_LIGHT_MEM_DEBUG /* light memory debugging */
|
||||||
|
|
||||||
#ifdef HAVE_purify
|
|
||||||
/* The following sets all new allocated memory to zero before use:
|
|
||||||
this can be used to eliminate unnecessary Purify warnings, but note that
|
|
||||||
it also masks many bugs Purify could detect. For detailed Purify analysis it
|
|
||||||
is best to remove the define below and look through the warnings one
|
|
||||||
by one. */
|
|
||||||
#define UNIV_SET_MEM_TO_ZERO
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#define UNIV_SQL_DEBUG
|
#define UNIV_SQL_DEBUG
|
||||||
#define UNIV_LOG_DEBUG
|
#define UNIV_LOG_DEBUG
|
||||||
|
@ -78,40 +78,19 @@ ut_mem_init(void);
|
|||||||
/*=============*/
|
/*=============*/
|
||||||
|
|
||||||
/**********************************************************************//**
|
/**********************************************************************//**
|
||||||
Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is
|
Allocates memory.
|
||||||
defined and set_to_zero is TRUE.
|
|
||||||
@return own: allocated memory */
|
@return own: allocated memory */
|
||||||
UNIV_INTERN
|
UNIV_INTERN
|
||||||
void*
|
void*
|
||||||
ut_malloc_low(
|
ut_malloc_low(
|
||||||
/*==========*/
|
/*==========*/
|
||||||
ulint n, /*!< in: number of bytes to allocate */
|
ulint n, /*!< in: number of bytes to allocate */
|
||||||
ibool set_to_zero, /*!< in: TRUE if allocated memory
|
ibool assert_on_error) /*!< in: if TRUE, we crash mysqld if
|
||||||
should be set to zero if
|
|
||||||
UNIV_SET_MEM_TO_ZERO is defined */
|
|
||||||
ibool assert_on_error); /*!< in: if TRUE, we crash mysqld if
|
|
||||||
the memory cannot be allocated */
|
the memory cannot be allocated */
|
||||||
|
__attribute__((malloc));
|
||||||
/**********************************************************************//**
|
/**********************************************************************//**
|
||||||
Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is
|
Allocates memory. */
|
||||||
defined.
|
#define ut_malloc(n) ut_malloc_low(n, TRUE)
|
||||||
@return own: allocated memory */
|
|
||||||
UNIV_INTERN
|
|
||||||
void*
|
|
||||||
ut_malloc(
|
|
||||||
/*======*/
|
|
||||||
ulint n); /*!< in: number of bytes to allocate */
|
|
||||||
#ifndef UNIV_HOTBACKUP
|
|
||||||
/**********************************************************************//**
|
|
||||||
Tests if malloc of n bytes would succeed. ut_malloc() asserts if memory runs
|
|
||||||
out. It cannot be used if we want to return an error message. Prints to
|
|
||||||
stderr a message if fails.
|
|
||||||
@return TRUE if succeeded */
|
|
||||||
UNIV_INTERN
|
|
||||||
ibool
|
|
||||||
ut_test_malloc(
|
|
||||||
/*===========*/
|
|
||||||
ulint n); /*!< in: try to allocate this many bytes */
|
|
||||||
#endif /* !UNIV_HOTBACKUP */
|
|
||||||
/**********************************************************************//**
|
/**********************************************************************//**
|
||||||
Frees a memory block allocated with ut_malloc. Freeing a NULL pointer is
|
Frees a memory block allocated with ut_malloc. Freeing a NULL pointer is
|
||||||
a nop. */
|
a nop. */
|
||||||
|
@ -223,11 +223,7 @@ mem_pool_create(
|
|||||||
|
|
||||||
pool = ut_malloc(sizeof(mem_pool_t));
|
pool = ut_malloc(sizeof(mem_pool_t));
|
||||||
|
|
||||||
/* We do not set the memory to zero (FALSE) in the pool,
|
pool->buf = ut_malloc_low(size, TRUE);
|
||||||
but only when allocated at a higher level in mem0mem.c.
|
|
||||||
This is to avoid masking useful Purify warnings. */
|
|
||||||
|
|
||||||
pool->buf = ut_malloc_low(size, FALSE, TRUE);
|
|
||||||
pool->size = size;
|
pool->size = size;
|
||||||
|
|
||||||
mutex_create(&pool->mutex, SYNC_MEM_POOL);
|
mutex_create(&pool->mutex, SYNC_MEM_POOL);
|
||||||
|
@ -111,9 +111,6 @@ os_mem_alloc_large(
|
|||||||
os_fast_mutex_lock(&ut_list_mutex);
|
os_fast_mutex_lock(&ut_list_mutex);
|
||||||
ut_total_allocated_memory += size;
|
ut_total_allocated_memory += size;
|
||||||
os_fast_mutex_unlock(&ut_list_mutex);
|
os_fast_mutex_unlock(&ut_list_mutex);
|
||||||
# ifdef UNIV_SET_MEM_TO_ZERO
|
|
||||||
memset(ptr, '\0', size);
|
|
||||||
# endif
|
|
||||||
UNIV_MEM_ALLOC(ptr, size);
|
UNIV_MEM_ALLOC(ptr, size);
|
||||||
return(ptr);
|
return(ptr);
|
||||||
}
|
}
|
||||||
|
@ -84,17 +84,13 @@ ut_mem_init(void)
|
|||||||
#endif /* !UNIV_HOTBACKUP */
|
#endif /* !UNIV_HOTBACKUP */
|
||||||
|
|
||||||
/**********************************************************************//**
|
/**********************************************************************//**
|
||||||
Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is
|
Allocates memory.
|
||||||
defined and set_to_zero is TRUE.
|
|
||||||
@return own: allocated memory */
|
@return own: allocated memory */
|
||||||
UNIV_INTERN
|
UNIV_INTERN
|
||||||
void*
|
void*
|
||||||
ut_malloc_low(
|
ut_malloc_low(
|
||||||
/*==========*/
|
/*==========*/
|
||||||
ulint n, /*!< in: number of bytes to allocate */
|
ulint n, /*!< in: number of bytes to allocate */
|
||||||
ibool set_to_zero, /*!< in: TRUE if allocated memory should be
|
|
||||||
set to zero if UNIV_SET_MEM_TO_ZERO is
|
|
||||||
defined */
|
|
||||||
ibool assert_on_error)/*!< in: if TRUE, we crash mysqld if the
|
ibool assert_on_error)/*!< in: if TRUE, we crash mysqld if the
|
||||||
memory cannot be allocated */
|
memory cannot be allocated */
|
||||||
{
|
{
|
||||||
@ -106,12 +102,6 @@ ut_malloc_low(
|
|||||||
ret = malloc(n);
|
ret = malloc(n);
|
||||||
ut_a(ret || !assert_on_error);
|
ut_a(ret || !assert_on_error);
|
||||||
|
|
||||||
#ifdef UNIV_SET_MEM_TO_ZERO
|
|
||||||
if (set_to_zero) {
|
|
||||||
memset(ret, '\0', n);
|
|
||||||
UNIV_MEM_ALLOC(ret, n);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,12 +189,6 @@ retry:
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (set_to_zero) {
|
|
||||||
#ifdef UNIV_SET_MEM_TO_ZERO
|
|
||||||
memset(ret, '\0', n + sizeof(ut_mem_block_t));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
UNIV_MEM_ALLOC(ret, n + sizeof(ut_mem_block_t));
|
UNIV_MEM_ALLOC(ret, n + sizeof(ut_mem_block_t));
|
||||||
|
|
||||||
((ut_mem_block_t*)ret)->size = n + sizeof(ut_mem_block_t);
|
((ut_mem_block_t*)ret)->size = n + sizeof(ut_mem_block_t);
|
||||||
@ -221,74 +205,10 @@ retry:
|
|||||||
void* ret = malloc(n);
|
void* ret = malloc(n);
|
||||||
ut_a(ret || !assert_on_error);
|
ut_a(ret || !assert_on_error);
|
||||||
|
|
||||||
# ifdef UNIV_SET_MEM_TO_ZERO
|
|
||||||
if (set_to_zero) {
|
|
||||||
memset(ret, '\0', n);
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
return(ret);
|
return(ret);
|
||||||
#endif /* !UNIV_HOTBACKUP */
|
#endif /* !UNIV_HOTBACKUP */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************//**
|
|
||||||
Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is
|
|
||||||
defined.
|
|
||||||
@return own: allocated memory */
|
|
||||||
UNIV_INTERN
|
|
||||||
void*
|
|
||||||
ut_malloc(
|
|
||||||
/*======*/
|
|
||||||
ulint n) /*!< in: number of bytes to allocate */
|
|
||||||
{
|
|
||||||
#ifndef UNIV_HOTBACKUP
|
|
||||||
return(ut_malloc_low(n, TRUE, TRUE));
|
|
||||||
#else /* !UNIV_HOTBACKUP */
|
|
||||||
return(malloc(n));
|
|
||||||
#endif /* !UNIV_HOTBACKUP */
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef UNIV_HOTBACKUP
|
|
||||||
/**********************************************************************//**
|
|
||||||
Tests if malloc of n bytes would succeed. ut_malloc() asserts if memory runs
|
|
||||||
out. It cannot be used if we want to return an error message. Prints to
|
|
||||||
stderr a message if fails.
|
|
||||||
@return TRUE if succeeded */
|
|
||||||
UNIV_INTERN
|
|
||||||
ibool
|
|
||||||
ut_test_malloc(
|
|
||||||
/*===========*/
|
|
||||||
ulint n) /*!< in: try to allocate this many bytes */
|
|
||||||
{
|
|
||||||
void* ret;
|
|
||||||
|
|
||||||
ret = malloc(n);
|
|
||||||
|
|
||||||
if (ret == NULL) {
|
|
||||||
ut_print_timestamp(stderr);
|
|
||||||
fprintf(stderr,
|
|
||||||
" InnoDB: Error: cannot allocate"
|
|
||||||
" %lu bytes of memory for\n"
|
|
||||||
"InnoDB: a BLOB with malloc! Total allocated memory\n"
|
|
||||||
"InnoDB: by InnoDB %lu bytes."
|
|
||||||
" Operating system errno: %d\n"
|
|
||||||
"InnoDB: Check if you should increase"
|
|
||||||
" the swap file or\n"
|
|
||||||
"InnoDB: ulimits of your operating system.\n"
|
|
||||||
"InnoDB: On FreeBSD check you have"
|
|
||||||
" compiled the OS with\n"
|
|
||||||
"InnoDB: a big enough maximum process size.\n",
|
|
||||||
(ulong) n,
|
|
||||||
(ulong) ut_total_allocated_memory,
|
|
||||||
(int) errno);
|
|
||||||
return(FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
free(ret);
|
|
||||||
|
|
||||||
return(TRUE);
|
|
||||||
}
|
|
||||||
#endif /* !UNIV_HOTBACKUP */
|
|
||||||
|
|
||||||
/**********************************************************************//**
|
/**********************************************************************//**
|
||||||
Frees a memory block allocated with ut_malloc. Freeing a NULL pointer is
|
Frees a memory block allocated with ut_malloc. Freeing a NULL pointer is
|
||||||
a nop. */
|
a nop. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user