mirror of
https://github.com/MariaDB/server.git
synced 2025-01-19 21:42:35 +01:00
branches/zip: mem_heap_create_block(), mem_heap_create_func():
Remove the unused parameter init_block. mem_heap_fast_create(): Remove. struct mem_block_info_struct: Remove the field init_block.
This commit is contained in:
parent
933d660032
commit
e24afbc387
4 changed files with 21 additions and 79 deletions
|
@ -68,28 +68,20 @@ Use this macro instead of the corresponding function! Macro for memory
|
|||
heap creation. */
|
||||
|
||||
#define mem_heap_create(N) mem_heap_create_func(\
|
||||
(N), NULL, MEM_HEAP_DYNAMIC, __FILE__, __LINE__)
|
||||
(N), MEM_HEAP_DYNAMIC, __FILE__, __LINE__)
|
||||
/******************************************************************
|
||||
Use this macro instead of the corresponding function! Macro for memory
|
||||
heap creation. */
|
||||
|
||||
#define mem_heap_create_in_buffer(N) mem_heap_create_func(\
|
||||
(N), NULL, MEM_HEAP_BUFFER, __FILE__, __LINE__)
|
||||
(N), MEM_HEAP_BUFFER, __FILE__, __LINE__)
|
||||
/******************************************************************
|
||||
Use this macro instead of the corresponding function! Macro for memory
|
||||
heap creation. */
|
||||
|
||||
#define mem_heap_create_in_btr_search(N) mem_heap_create_func(\
|
||||
(N), NULL, MEM_HEAP_BTR_SEARCH | MEM_HEAP_BUFFER,\
|
||||
(N), MEM_HEAP_BTR_SEARCH | MEM_HEAP_BUFFER,\
|
||||
__FILE__, __LINE__)
|
||||
/******************************************************************
|
||||
Use this macro instead of the corresponding function! Macro for fast
|
||||
memory heap creation. An initial block of memory B is given by the
|
||||
caller, N is its size, and this memory block is not freed by
|
||||
mem_heap_free. See the parameter comment in mem_heap_create_func below. */
|
||||
|
||||
#define mem_heap_fast_create(N, B) mem_heap_create_func(\
|
||||
(N), (B), MEM_HEAP_DYNAMIC, __FILE__, __LINE__)
|
||||
|
||||
/******************************************************************
|
||||
Use this macro instead of the corresponding function! Macro for memory
|
||||
|
@ -111,19 +103,7 @@ mem_heap_create_func(
|
|||
ulint n, /* in: desired start block size,
|
||||
this means that a single user buffer
|
||||
of size n will fit in the block,
|
||||
0 creates a default size block;
|
||||
if init_block is not NULL, n tells
|
||||
its size in bytes */
|
||||
void* init_block, /* in: if very fast creation is
|
||||
wanted, the caller can reserve some
|
||||
memory from its stack, for example,
|
||||
and pass it as the the initial block
|
||||
to the heap: then no OS call of malloc
|
||||
is needed at the creation. CAUTION:
|
||||
the caller must make sure the initial
|
||||
block is not unintentionally erased
|
||||
(if allocated in the stack), before
|
||||
the memory heap is explicitly freed. */
|
||||
0 creates a default size block */
|
||||
ulint type, /* in: heap type */
|
||||
const char* file_name, /* in: file name where created */
|
||||
ulint line); /* in: line where created */
|
||||
|
@ -225,8 +205,8 @@ mem_alloc_func(
|
|||
/* out, own: free storage */
|
||||
ulint n, /* in: desired number of bytes */
|
||||
const char* file_name, /* in: file name where created */
|
||||
ulint line /* in: line where created */
|
||||
);
|
||||
ulint line); /* in: line where created */
|
||||
|
||||
/*******************************************************************
|
||||
NOTE: Use the corresponding macro instead of this function.
|
||||
Allocates a single buffer of memory from the dynamic memory of
|
||||
|
@ -239,8 +219,8 @@ mem_alloc_func_noninline(
|
|||
/* out, own: free storage */
|
||||
ulint n, /* in: desired number of bytes */
|
||||
const char* file_name, /* in: file name where created */
|
||||
ulint line /* in: line where created */
|
||||
);
|
||||
ulint line); /* in: line where created */
|
||||
|
||||
/******************************************************************
|
||||
Use this macro instead of the corresponding function!
|
||||
Macro for memory buffer freeing */
|
||||
|
@ -388,9 +368,6 @@ struct mem_block_info_struct {
|
|||
ulint len; /* physical length of this block in bytes */
|
||||
ulint type; /* type of heap: MEM_HEAP_DYNAMIC, or
|
||||
MEM_HEAP_BUF possibly ORed to MEM_HEAP_BTR_SEARCH */
|
||||
ibool init_block; /* TRUE if this is the first block used in fast
|
||||
creation of a heap: the memory will be freed
|
||||
by the creator, not by mem_heap_free */
|
||||
ulint free; /* offset in bytes of the first free position for
|
||||
user data in the block */
|
||||
ulint start; /* the value of the struct field 'free' at the
|
||||
|
|
|
@ -21,10 +21,7 @@ mem_heap_create_block(
|
|||
MEM_HEAP_BTR_SEARCH type heaps) */
|
||||
mem_heap_t* heap, /* in: memory heap or NULL if first block
|
||||
should be created */
|
||||
ulint n, /* in: number of bytes needed for user data, or
|
||||
if init_block is not NULL, its size in bytes */
|
||||
void* init_block, /* in: init block in fast create,
|
||||
type must be MEM_HEAP_DYNAMIC */
|
||||
ulint n, /* in: number of bytes needed for user data */
|
||||
ulint type, /* in: type of heap: MEM_HEAP_DYNAMIC or
|
||||
MEM_HEAP_BUFFER */
|
||||
const char* file_name,/* in: file name where created */
|
||||
|
@ -386,34 +383,19 @@ mem_heap_create_func(
|
|||
ulint n, /* in: desired start block size,
|
||||
this means that a single user buffer
|
||||
of size n will fit in the block,
|
||||
0 creates a default size block;
|
||||
if init_block is not NULL, n tells
|
||||
its size in bytes */
|
||||
void* init_block, /* in: if very fast creation is
|
||||
wanted, the caller can reserve some
|
||||
memory from its stack, for example,
|
||||
and pass it as the the initial block
|
||||
to the heap: then no OS call of malloc
|
||||
is needed at the creation. CAUTION:
|
||||
the caller must make sure the initial
|
||||
block is not unintentionally erased
|
||||
(if allocated in the stack), before
|
||||
the memory heap is explicitly freed. */
|
||||
0 creates a default size block */
|
||||
ulint type, /* in: heap type */
|
||||
const char* file_name, /* in: file name where created */
|
||||
ulint line) /* in: line where created */
|
||||
{
|
||||
mem_block_t* block;
|
||||
|
||||
if (n > 0) {
|
||||
block = mem_heap_create_block(NULL, n, init_block, type,
|
||||
file_name, line);
|
||||
} else {
|
||||
block = mem_heap_create_block(NULL, MEM_BLOCK_START_SIZE,
|
||||
init_block, type,
|
||||
file_name, line);
|
||||
if (!n) {
|
||||
n = MEM_BLOCK_START_SIZE;
|
||||
}
|
||||
|
||||
block = mem_heap_create_block(NULL, n, type, file_name, line);
|
||||
|
||||
if (block == NULL) {
|
||||
|
||||
return(NULL);
|
||||
|
@ -490,14 +472,12 @@ mem_alloc_func(
|
|||
/* out, own: free storage */
|
||||
ulint n, /* in: desired number of bytes */
|
||||
const char* file_name, /* in: file name where created */
|
||||
ulint line /* in: line where created */
|
||||
)
|
||||
ulint line) /* in: line where created */
|
||||
{
|
||||
mem_heap_t* heap;
|
||||
void* buf;
|
||||
|
||||
heap = mem_heap_create_func(n, NULL, MEM_HEAP_DYNAMIC, file_name,
|
||||
line);
|
||||
heap = mem_heap_create_func(n, MEM_HEAP_DYNAMIC, file_name, line);
|
||||
|
||||
/* Note that as we created the first block in the heap big enough
|
||||
for the buffer requested by the caller, the buffer will be in the
|
||||
|
|
|
@ -329,10 +329,7 @@ mem_heap_create_block(
|
|||
MEM_HEAP_BTR_SEARCH type heaps) */
|
||||
mem_heap_t* heap, /* in: memory heap or NULL if first block
|
||||
should be created */
|
||||
ulint n, /* in: number of bytes needed for user data, or
|
||||
if init_block is not NULL, its size in bytes */
|
||||
void* init_block, /* in: init block in fast create,
|
||||
type must be MEM_HEAP_DYNAMIC */
|
||||
ulint n, /* in: number of bytes needed for user data */
|
||||
ulint type, /* in: type of heap: MEM_HEAP_DYNAMIC or
|
||||
MEM_HEAP_BUFFER */
|
||||
const char* file_name,/* in: file name where created */
|
||||
|
@ -351,13 +348,7 @@ mem_heap_create_block(
|
|||
|
||||
/* In dynamic allocation, calculate the size: block header + data. */
|
||||
|
||||
if (init_block != NULL) {
|
||||
ut_ad(type == MEM_HEAP_DYNAMIC);
|
||||
ut_ad(n > MEM_BLOCK_START_SIZE + MEM_BLOCK_HEADER_SIZE);
|
||||
len = n;
|
||||
block = init_block;
|
||||
|
||||
} else if (type == MEM_HEAP_DYNAMIC) {
|
||||
if (type == MEM_HEAP_DYNAMIC) {
|
||||
|
||||
len = MEM_BLOCK_HEADER_SIZE + MEM_SPACE_NEEDED(n);
|
||||
block = mem_area_alloc(len, mem_comm_pool);
|
||||
|
@ -416,7 +407,6 @@ mem_heap_create_block(
|
|||
mem_block_set_start(block, MEM_BLOCK_HEADER_SIZE);
|
||||
|
||||
block->free_block = NULL;
|
||||
block->init_block = (init_block != NULL);
|
||||
|
||||
ut_ad((ulint)MEM_BLOCK_HEADER_SIZE < len);
|
||||
|
||||
|
@ -465,7 +455,7 @@ mem_heap_add_block(
|
|||
new_size = n;
|
||||
}
|
||||
|
||||
new_block = mem_heap_create_block(heap, new_size, NULL, heap->type,
|
||||
new_block = mem_heap_create_block(heap, new_size, heap->type,
|
||||
heap->file_name, heap->line);
|
||||
if (new_block == NULL) {
|
||||
|
||||
|
@ -490,7 +480,6 @@ mem_heap_block_free(
|
|||
{
|
||||
ulint type;
|
||||
ulint len;
|
||||
ibool init_block;
|
||||
buf_block_t* buf_block;
|
||||
|
||||
if (block->magic_n != MEM_BLOCK_MAGIC_N) {
|
||||
|
@ -508,7 +497,6 @@ mem_heap_block_free(
|
|||
#endif
|
||||
type = heap->type;
|
||||
len = block->len;
|
||||
init_block = block->init_block;
|
||||
buf_block = block->buf_block;
|
||||
block->magic_n = MEM_FREED_BLOCK_MAGIC_N;
|
||||
|
||||
|
@ -519,10 +507,7 @@ mem_heap_block_free(
|
|||
mem_erase_buf((byte*)block, len);
|
||||
#endif
|
||||
|
||||
if (init_block) {
|
||||
/* Do not have to free: do nothing */
|
||||
|
||||
} else if (type == MEM_HEAP_DYNAMIC) {
|
||||
if (type == MEM_HEAP_DYNAMIC) {
|
||||
|
||||
ut_ad(!buf_block);
|
||||
mem_area_free(block, mem_comm_pool);
|
||||
|
|
|
@ -429,7 +429,7 @@ rec_get_offsets_func(
|
|||
|| UNIV_UNLIKELY(rec_offs_get_n_alloc(offsets) < size)) {
|
||||
if (!*heap) {
|
||||
*heap = mem_heap_create_func(size * sizeof(ulint),
|
||||
NULL, MEM_HEAP_DYNAMIC,
|
||||
MEM_HEAP_DYNAMIC,
|
||||
file, line);
|
||||
}
|
||||
offsets = mem_heap_alloc(*heap, size * sizeof(ulint));
|
||||
|
|
Loading…
Reference in a new issue