Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
f24fa9e6
Commit
f24fa9e6
authored
Jun 19, 2007
by
marko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
branches/zip: Define mem_heap_calloc() and mem_calloc(). Use them
when allocating zero-filled memory.
parent
b3b01c1c
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
45 additions
and
22 deletions
+45
-22
data/data0data.c
data/data0data.c
+3
-2
dict/dict0crea.c
dict/dict0crea.c
+2
-4
dict/dict0dict.c
dict/dict0dict.c
+4
-8
dict/dict0mem.c
dict/dict0mem.c
+1
-2
include/mem0mem.h
include/mem0mem.h
+15
-0
include/mem0mem.ic
include/mem0mem.ic
+17
-0
page/page0page.c
page/page0page.c
+1
-2
page/page0zip.c
page/page0zip.c
+1
-2
row/row0merge.c
row/row0merge.c
+1
-2
No files found.
data/data0data.c
View file @
f24fa9e6
...
...
@@ -727,8 +727,9 @@ skip_field:
/* Set the extern field reference in dfield to zero */
dfield
->
len
=
BTR_EXTERN_FIELD_REF_SIZE
;
dfield
->
data
=
mem_heap_alloc
(
heap
,
BTR_EXTERN_FIELD_REF_SIZE
);
memset
(
dfield
->
data
,
0
,
BTR_EXTERN_FIELD_REF_SIZE
);
dfield
->
data
=
mem_heap_calloc
(
heap
,
BTR_EXTERN_FIELD_REF_SIZE
);
UNIV_MEM_ALLOC
(
dfield
->
data
,
BTR_EXTERN_FIELD_REF_SIZE
);
n_fields
++
;
ut_ad
(
n_fields
<
dtuple_get_n_fields
(
entry
));
}
...
...
dict/dict0crea.c
View file @
f24fa9e6
...
...
@@ -88,16 +88,14 @@ dict_create_sys_tables_tuple(
/* 6: MIX_ID (obsolete) ---------------------------*/
dfield
=
dtuple_get_nth_field
(
entry
,
4
);
ptr
=
mem_heap_alloc
(
heap
,
8
);
memset
(
ptr
,
0
,
8
);
ptr
=
mem_heap_calloc
(
heap
,
8
);
dfield_set_data
(
dfield
,
ptr
,
8
);
/* 7: MIX_LEN (obsolete) --------------------------*/
dfield
=
dtuple_get_nth_field
(
entry
,
5
);
ptr
=
mem_heap_alloc
(
heap
,
4
);
memset
(
ptr
,
0
,
4
);
ptr
=
mem_heap_calloc
(
heap
,
4
);
dfield_set_data
(
dfield
,
ptr
,
4
);
/* 8: CLUSTER_NAME ---------------------*/
...
...
dict/dict0dict.c
View file @
f24fa9e6
...
...
@@ -1742,8 +1742,7 @@ dict_index_build_internal_clust(
}
/* Remember the table columns already contained in new_index */
indexed
=
mem_alloc
(
table
->
n_cols
*
sizeof
*
indexed
);
memset
(
indexed
,
0
,
table
->
n_cols
*
sizeof
*
indexed
);
indexed
=
mem_calloc
(
table
->
n_cols
*
sizeof
*
indexed
);
/* Mark with 0 the table columns already contained in new_index */
for
(
i
=
0
;
i
<
new_index
->
n_def
;
i
++
)
{
...
...
@@ -1828,8 +1827,7 @@ dict_index_build_internal_non_clust(
dict_index_copy
(
new_index
,
index
,
table
,
0
,
index
->
n_fields
);
/* Remember the table columns already contained in new_index */
indexed
=
mem_alloc
(
table
->
n_cols
*
sizeof
*
indexed
);
memset
(
indexed
,
0
,
table
->
n_cols
*
sizeof
*
indexed
);
indexed
=
mem_calloc
(
table
->
n_cols
*
sizeof
*
indexed
);
/* Mark with 0 table columns already contained in new_index */
for
(
i
=
0
;
i
<
new_index
->
n_def
;
i
++
)
{
...
...
@@ -4653,8 +4651,7 @@ dict_undo_create_element(
ut_a
(
trx
->
dict_undo_list
);
dict_undo
=
mem_alloc
(
sizeof
(
*
dict_undo
));
memset
(
dict_undo
,
'\0'
,
sizeof
(
*
dict_undo
));
dict_undo
=
mem_calloc
(
sizeof
*
dict_undo
);
UT_LIST_ADD_LAST
(
node
,
*
trx
->
dict_undo_list
,
dict_undo
);
...
...
@@ -4716,8 +4713,7 @@ dict_redo_create_element(
ut_a
(
trx
->
dict_redo_list
);
dict_redo
=
mem_alloc
(
sizeof
(
*
dict_redo
));
memset
(
dict_redo
,
'\0'
,
sizeof
(
*
dict_redo
));
dict_redo
=
mem_calloc
(
sizeof
*
dict_redo
);
UT_LIST_ADD_LAST
(
node
,
*
trx
->
dict_redo_list
,
dict_redo
);
...
...
dict/dict0mem.c
View file @
f24fa9e6
...
...
@@ -191,8 +191,7 @@ dict_mem_table_add_col(
}
if
(
UNIV_LIKELY
(
i
)
&&
UNIV_UNLIKELY
(
!
table
->
col_names
))
{
/* All preceding column names are empty. */
char
*
s
=
mem_heap_alloc
(
heap
,
table
->
n_def
);
memset
(
s
,
0
,
table
->
n_def
);
char
*
s
=
mem_heap_calloc
(
heap
,
table
->
n_def
);
table
->
col_names
=
s
;
}
...
...
include/mem0mem.h
View file @
f24fa9e6
...
...
@@ -162,6 +162,19 @@ mem_heap_free_func_noninline(
const
char
*
file_name
,
/* in: file name where freed */
ulint
line
);
/* in: line where freed */
/*******************************************************************
Allocates and zero-fills n bytes of memory from a memory heap. */
UNIV_INLINE
void
*
mem_heap_calloc
(
/*============*/
/* out: allocated storage, NULL if did not
succeed (only possible for
MEM_HEAP_BTR_SEARCH type heaps) */
mem_heap_t
*
heap
,
/* in: memory heap */
ulint
n
);
/* in: number of bytes; if the heap is allowed
to grow into the buffer pool, this must be
<= MEM_MAX_ALLOC_IN_BUF */
/*******************************************************************
Allocates n bytes of memory from a memory heap. */
UNIV_INLINE
void
*
...
...
@@ -249,6 +262,8 @@ mem_heap_get_size(
Use this macro instead of the corresponding function!
Macro for memory buffer allocation */
#define mem_calloc(N) memset(mem_alloc(N), 0, (N));
#define mem_alloc(N) mem_alloc_func((N), __FILE__, __LINE__)
/******************************************************************
Use this macro instead of the corresponding function!
...
...
include/mem0mem.ic
View file @
f24fa9e6
...
...
@@ -119,6 +119,23 @@ mem_block_get_start(mem_block_t* block)
return(block->start);
}
/*******************************************************************
Allocates and zero-fills n bytes of memory from a memory heap. */
UNIV_INLINE
void*
mem_heap_calloc(
/*============*/
/* out: allocated storage, NULL if did not
succeed (only possible for
MEM_HEAP_BTR_SEARCH type heaps) */
mem_heap_t* heap, /* in: memory heap */
ulint n) /* in: number of bytes; if the heap is allowed
to grow into the buffer pool, this must be
<= MEM_MAX_ALLOC_IN_BUF */
{
return(memset(mem_heap_alloc(heap, n), 0, n));
}
/*******************************************************************
Allocates n bytes of memory from a memory heap. */
UNIV_INLINE
...
...
page/page0page.c
View file @
f24fa9e6
...
...
@@ -2259,8 +2259,7 @@ page_validate(
/* The following buffer is used to check that the
records in the page record heap do not overlap */
buf
=
mem_heap_alloc
(
heap
,
UNIV_PAGE_SIZE
);
memset
(
buf
,
0
,
UNIV_PAGE_SIZE
);
buf
=
mem_heap_calloc
(
heap
,
UNIV_PAGE_SIZE
);
/* Check first that the record heap and the directory do not
overlap. */
...
...
page/page0zip.c
View file @
f24fa9e6
...
...
@@ -1082,8 +1082,7 @@ page_zip_compress(
+
UNIV_PAGE_SIZE
*
4
+
(
512
<<
MAX_MEM_LEVEL
));
recs
=
mem_heap_alloc
(
heap
,
n_dense
*
sizeof
*
recs
);
memset
(
recs
,
0
,
n_dense
*
sizeof
*
recs
);
recs
=
mem_heap_calloc
(
heap
,
n_dense
*
sizeof
*
recs
);
fields
=
mem_heap_alloc
(
heap
,
(
n_fields
+
1
)
*
2
);
...
...
row/row0merge.c
View file @
f24fa9e6
...
...
@@ -103,8 +103,7 @@ row_merge_buf_create_low(
{
row_merge_buf_t
*
buf
;
buf
=
mem_heap_alloc
(
heap
,
buf_size
);
memset
(
buf
,
0
,
buf_size
);
buf
=
mem_heap_calloc
(
heap
,
buf_size
);
buf
->
heap
=
heap
;
buf
->
index
=
index
;
buf
->
max_tuples
=
max_tuples
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment