Commit 8634d343 authored by marko's avatar marko

branches/zip: Rename mem_heap_calloc() and mem_calloc() to

mem_heap_zalloc() and mem_zalloc(), because calloc() in the C runtime
library takes two size parameters, not one.

mem_heap_zalloc(): Add debug assertions.  Document that the return value
is never NULL.
parent 66f6a5ac
......@@ -3165,7 +3165,7 @@ btr_estimate_number_of_different_key_vals(
n_cols = dict_index_get_n_unique(index);
n_diff = mem_calloc((n_cols + 1) * sizeof(ib_longlong));
n_diff = mem_zalloc((n_cols + 1) * sizeof(ib_longlong));
/* We sample some pages in the index to get an estimate */
......
......@@ -674,7 +674,7 @@ skip_field:
/* Set the extern field reference in dfield to zero */
dfield_set_data(dfield,
mem_heap_calloc(heap,
mem_heap_zalloc(heap,
BTR_EXTERN_FIELD_REF_SIZE),
BTR_EXTERN_FIELD_REF_SIZE);
dfield_set_ext(dfield);
......
......@@ -88,14 +88,14 @@ dict_create_sys_tables_tuple(
/* 6: MIX_ID (obsolete) ---------------------------*/
dfield = dtuple_get_nth_field(entry, 4);
ptr = mem_heap_calloc(heap, 8);
ptr = mem_heap_zalloc(heap, 8);
dfield_set_data(dfield, ptr, 8);
/* 7: MIX_LEN (obsolete) --------------------------*/
dfield = dtuple_get_nth_field(entry, 5);
ptr = mem_heap_calloc(heap, 4);
ptr = mem_heap_zalloc(heap, 4);
dfield_set_data(dfield, ptr, 4);
/* 8: CLUSTER_NAME ---------------------*/
......
......@@ -1623,7 +1623,7 @@ dict_index_build_internal_clust(
}
/* Remember the table columns already contained in new_index */
indexed = mem_calloc(table->n_cols * sizeof *indexed);
indexed = mem_zalloc(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++) {
......@@ -1708,7 +1708,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_calloc(table->n_cols * sizeof *indexed);
indexed = mem_zalloc(table->n_cols * sizeof *indexed);
/* Mark with 0 table columns already contained in new_index */
for (i = 0; i < new_index->n_def; i++) {
......@@ -4520,7 +4520,7 @@ dict_undo_create_element(
ut_a(trx->dict_undo_list);
dict_undo = mem_calloc(sizeof *dict_undo);
dict_undo = mem_zalloc(sizeof *dict_undo);
UT_LIST_ADD_LAST(node, *trx->dict_undo_list, dict_undo);
......@@ -4582,7 +4582,7 @@ dict_redo_create_element(
ut_a(trx->dict_redo_list);
dict_redo = mem_calloc(sizeof *dict_redo);
dict_redo = mem_zalloc(sizeof *dict_redo);
UT_LIST_ADD_LAST(node, *trx->dict_redo_list, dict_redo);
......
......@@ -196,7 +196,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_calloc(heap, table->n_def);
char* s = mem_heap_zalloc(heap, table->n_def);
table->col_names = s;
}
......
......@@ -122,11 +122,9 @@ mem_heap_free_func(
Allocates and zero-fills n bytes of memory from a memory heap. */
UNIV_INLINE
void*
mem_heap_calloc(
mem_heap_zalloc(
/*============*/
/* out: allocated storage, NULL if did not
succeed (only possible for
MEM_HEAP_BTR_SEARCH type heaps) */
/* out: allocated, zero-filled storage */
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
......@@ -199,7 +197,7 @@ 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_zalloc(N) memset(mem_alloc(N), 0, (N));
#define mem_alloc(N) mem_alloc_func((N), __FILE__, __LINE__)
/*******************************************************************
......
......@@ -123,16 +123,16 @@ mem_block_get_start(mem_block_t* block)
Allocates and zero-fills n bytes of memory from a memory heap. */
UNIV_INLINE
void*
mem_heap_calloc(
mem_heap_zalloc(
/*============*/
/* out: allocated storage, NULL if did not
succeed (only possible for
MEM_HEAP_BTR_SEARCH type heaps) */
/* out: allocated, zero-filled storage */
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 */
{
ut_ad(heap);
ut_ad(!(heap->type & MEM_HEAP_BTR_SEARCH));
return(memset(mem_heap_alloc(heap, n), 0, n));
}
......
......@@ -2245,7 +2245,7 @@ page_validate(
/* The following buffer is used to check that the
records in the page record heap do not overlap */
buf = mem_heap_calloc(heap, UNIV_PAGE_SIZE);
buf = mem_heap_zalloc(heap, UNIV_PAGE_SIZE);
/* Check first that the record heap and the directory do not
overlap. */
......
......@@ -1082,7 +1082,7 @@ page_zip_compress(
+ UNIV_PAGE_SIZE * 4
+ (512 << MAX_MEM_LEVEL));
recs = mem_heap_calloc(heap, n_dense * sizeof *recs);
recs = mem_heap_zalloc(heap, n_dense * sizeof *recs);
fields = mem_heap_alloc(heap, (n_fields + 1) * 2);
......
......@@ -96,7 +96,7 @@ row_merge_buf_create_low(
ut_ad(max_tuples <= sizeof(row_merge_block_t));
ut_ad(max_tuples < buf_size);
buf = mem_heap_calloc(heap, buf_size);
buf = mem_heap_zalloc(heap, buf_size);
buf->heap = heap;
buf->index = index;
buf->max_tuples = max_tuples;
......
......@@ -579,7 +579,7 @@ row_create_prebuilt(
heap = mem_heap_create(sizeof *prebuilt + 128);
prebuilt = mem_heap_calloc(heap, sizeof *prebuilt);
prebuilt = mem_heap_zalloc(heap, sizeof *prebuilt);
prebuilt->magic_n = ROW_PREBUILT_ALLOCATED;
prebuilt->magic_n2 = ROW_PREBUILT_ALLOCATED;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment