summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2007-05-29 20:02:34 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2007-05-29 20:02:34 (GMT)
commitbdcbada3f282774f709e17990dc7f77b24919950 (patch)
treef2f1264f0a3c7ac08b78eb314358ce1ee62aa5a5 /src
parent7b0fa3950e74ea0c9bfe3baa07a48e2d451ebab5 (diff)
downloadhdf5-bdcbada3f282774f709e17990dc7f77b24919950.zip
hdf5-bdcbada3f282774f709e17990dc7f77b24919950.tar.gz
hdf5-bdcbada3f282774f709e17990dc7f77b24919950.tar.bz2
[svn-r13814] Description:
Change back to clearing memory buffers by default, but give users option to disable this, for performance reasons (--disable-clear-file-buffers). Also, add configure option (--enable-using-memchecker) to conveniently control making the library "play nice" with memory checking tools like valgrind and purify. Tested on: Mac OS X/32 10.4.9 (amazon) FreeBSD/32 6.2 (duty) Linux/32 2.6 (kagiso)
Diffstat (limited to 'src')
-rw-r--r--src/H5A.c8
-rw-r--r--src/H5B2int.c18
-rw-r--r--src/H5Dcontig.c4
-rw-r--r--src/H5Distore.c14
-rw-r--r--src/H5FD.c33
-rw-r--r--src/H5FDcore.c4
-rw-r--r--src/H5FLprivate.h2
-rw-r--r--src/H5Gname.c4
-rw-r--r--src/H5Gnode.c6
-rw-r--r--src/H5Gtraverse.c4
-rw-r--r--src/H5HFdblock.c4
-rw-r--r--src/H5HG.c12
-rw-r--r--src/H5Tcommit.c4
13 files changed, 60 insertions, 57 deletions
diff --git a/src/H5A.c b/src/H5A.c
index 35fdcf0..b7852ea 100644
--- a/src/H5A.c
+++ b/src/H5A.c
@@ -584,11 +584,11 @@ H5A_open_common(const H5G_loc_t *loc, H5A_t *attr)
HDassert(loc);
HDassert(attr);
-#if defined(H5_USING_PURIFY) || !defined(NDEBUG)
+#if defined(H5_USING_MEMCHECKER) || !defined(NDEBUG)
/* Clear object location */
if(H5O_loc_reset(&(attr->oloc)) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to reset location")
-#endif /* H5_USING_PURIFY */
+#endif /* H5_USING_MEMCHECKER */
/* Free any previous group hier. path */
if(H5G_name_free(&(attr->path)) < 0)
@@ -1989,7 +1989,7 @@ H5A_copy(H5A_t *_new_attr, const H5A_t *old_attr)
if(NULL == (new_attr->ds = H5S_copy(old_attr->ds, FALSE)))
HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, NULL, "unable to copy attribute dataspace")
-#if defined(H5_USING_PURIFY) || !defined(NDEBUG)
+#if defined(H5_USING_MEMCHECKER) || !defined(NDEBUG)
/* Clear object location */
if(H5O_loc_reset(&(new_attr->oloc)) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to reset location")
@@ -1997,7 +1997,7 @@ H5A_copy(H5A_t *_new_attr, const H5A_t *old_attr)
/* Clear path name */
if(H5G_name_reset(&(new_attr->path)) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to reset path")
-#endif /* H5_USING_PURIFY */
+#endif /* H5_USING_MEMCHECKER */
/* Copy the object location and group path */
if(H5O_loc_copy(&(new_attr->oloc), &(old_attr->oloc), H5_COPY_DEEP) < 0)
diff --git a/src/H5B2int.c b/src/H5B2int.c
index 615f8cd..5d71d43 100644
--- a/src/H5B2int.c
+++ b/src/H5B2int.c
@@ -173,9 +173,9 @@ H5B2_shared_init (H5F_t *f, H5B2_t *bt2, const H5B2_class_t *type,
/* Allocate "page" for node I/O */
if((shared->page = H5FL_BLK_MALLOC(node_page, shared->node_size)) == NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
-#ifdef H5_USING_PURIFY
-HDmemset(shared->page,0,shared->node_size);
-#endif /* H5_USING_PURIFY */
+#ifdef H5_CLEAR_MEMORY
+HDmemset(shared->page, 0, shared->node_size);
+#endif /* H5_CLEAR_MEMORY */
/* Allocate array of node info structs */
if((shared->node_info = H5FL_SEQ_MALLOC(H5B2_node_info_t, (size_t)(shared->depth + 1))) == NULL)
@@ -1946,9 +1946,9 @@ H5B2_create_leaf(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, H5B2_node_ptr_t *n
/* Allocate space for the native keys in memory */
if((leaf->leaf_native = (uint8_t *)H5FL_FAC_MALLOC(shared->node_info[0].nat_rec_fac)) == NULL)
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree leaf native keys")
-#ifdef H5_USING_PURIFY
+#ifdef H5_CLEAR_MEMORY
HDmemset(leaf->leaf_native, 0, shared->type->nrec_size * shared->node_info[0].max_nrec);
-#endif /* H5_USING_PURIFY */
+#endif /* H5_CLEAR_MEMORY */
/* Set number of records */
leaf->nrec = 0;
@@ -2019,16 +2019,16 @@ H5B2_create_internal(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
/* Allocate space for the native keys in memory */
if((internal->int_native = (uint8_t *)H5FL_FAC_MALLOC(shared->node_info[depth].nat_rec_fac)) == NULL)
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree internal native keys")
-#ifdef H5_USING_PURIFY
+#ifdef H5_CLEAR_MEMORY
HDmemset(internal->int_native, 0, shared->type->nrec_size * shared->node_info[depth].max_nrec);
-#endif /* H5_USING_PURIFY */
+#endif /* H5_CLEAR_MEMORY */
/* Allocate space for the node pointers in memory */
if((internal->node_ptrs = (H5B2_node_ptr_t *)H5FL_FAC_MALLOC(shared->node_info[depth].node_ptr_fac)) == NULL)
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree internal node pointers")
-#ifdef H5_USING_PURIFY
+#ifdef H5_CLEAR_MEMORY
HDmemset(internal->node_ptrs, 0, sizeof(H5B2_node_ptr_t) * (shared->node_info[depth].max_nrec + 1));
-#endif /* H5_USING_PURIFY */
+#endif /* H5_CLEAR_MEMORY */
/* Set number of records & depth of the node */
internal->nrec = 0;
diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c
index e8fc4d0..6cdee41 100644
--- a/src/H5Dcontig.c
+++ b/src/H5Dcontig.c
@@ -753,10 +753,10 @@ H5D_contig_writevv(const H5D_io_info_t *io_info,
/* Allocate room for the data sieve buffer */
if (NULL==(dset_contig->sieve_buf=H5FL_BLK_MALLOC(sieve_buf,dset_contig->sieve_buf_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
-#ifdef H5_USING_PURIFY
+#ifdef H5_CLEAR_MEMORY
if(dset_contig->sieve_size > size)
HDmemset(dset_contig->sieve_buf + size, 0, (dset_contig->sieve_size - size));
-#endif /* H5_USING_PURIFY */
+#endif /* H5_CLEAR_MEMORY */
/* Determine the new sieve buffer size & location */
dset_contig->sieve_loc=addr;
diff --git a/src/H5Distore.c b/src/H5Distore.c
index f770e98..702b887 100644
--- a/src/H5Distore.c
+++ b/src/H5Distore.c
@@ -1526,9 +1526,9 @@ H5D_istore_shared_create (const H5F_t *f, H5O_layout_t *layout)
assert(shared->sizeof_rnode);
if(NULL==(shared->page=H5FL_BLK_MALLOC(chunk_page,shared->sizeof_rnode)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree page")
-#ifdef H5_USING_PURIFY
-HDmemset(shared->page,0,shared->sizeof_rnode);
-#endif /* H5_USING_PURIFY */
+#ifdef H5_CLEAR_MEMORY
+HDmemset(shared->page, 0, shared->sizeof_rnode);
+#endif /* H5_CLEAR_MEMORY */
if(NULL==(shared->nkey=H5FL_SEQ_MALLOC(size_t,(size_t)(2*H5F_KVALUE(f,H5B_ISTORE)+1))))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree page")
@@ -1859,10 +1859,10 @@ H5D_istore_lock(const H5D_io_info_t *io_info, H5D_istore_ud1_t *udata,
HDmemset(chunk, 0, chunk_size);
} /* end else */
} /* end if */
-#ifdef H5_USING_PURIFY
-else
- HDmemset(chunk, 0, chunk_size);
-#endif /* H5_USING_PURIFY */
+#ifdef H5_CLEAR_MEMORY
+ else
+ HDmemset(chunk, 0, chunk_size);
+#endif /* H5_CLEAR_MEMORY */
#ifdef H5D_ISTORE_DEBUG
rdcc->ninits++;
#endif /* H5D_ISTORE_DEBUG */
diff --git a/src/H5FD.c b/src/H5FD.c
index 8dd72cd..198757b 100644
--- a/src/H5FD.c
+++ b/src/H5FD.c
@@ -3491,9 +3491,9 @@ H5FD_write(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t si
/* Reallocate the metadata accumulator buffer */
if((file->meta_accum=H5FL_BLK_REALLOC(meta_accum,file->meta_accum,file->accum_buf_size))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer")
-#ifdef H5_USING_PURIFY
-HDmemset(file->meta_accum+file->accum_size,0,(file->accum_buf_size-file->accum_size));
-#endif /* H5_USING_PURIFY */
+#ifdef H5_CLEAR_MEMORY
+HDmemset(file->meta_accum + file->accum_size, 0, (file->accum_buf_size - (file->accum_size + size)));
+#endif /* H5_CLEAR_MEMORY */
} /* end if */
/* Move the existing metadata to the proper location */
@@ -3519,9 +3519,9 @@ HDmemset(file->meta_accum+file->accum_size,0,(file->accum_buf_size-file->accum_s
/* Reallocate the metadata accumulator buffer */
if((file->meta_accum=H5FL_BLK_REALLOC(meta_accum,file->meta_accum,file->accum_buf_size))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer")
-#ifdef H5_USING_PURIFY
-HDmemset(file->meta_accum+file->accum_size,0,(file->accum_buf_size-file->accum_size));
-#endif /* H5_USING_PURIFY */
+#ifdef H5_CLEAR_MEMORY
+HDmemset(file->meta_accum + file->accum_size + size, 0, (file->accum_buf_size - (file->accum_size + size)));
+#endif /* H5_CLEAR_MEMORY */
} /* end if */
/* Copy the new metadata to the end */
@@ -3554,9 +3554,9 @@ HDmemset(file->meta_accum+file->accum_size,0,(file->accum_buf_size-file->accum_s
/* Reallocate the metadata accumulator buffer */
if((file->meta_accum=H5FL_BLK_REALLOC(meta_accum,file->meta_accum,file->accum_buf_size))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer")
-#ifdef H5_USING_PURIFY
-HDmemset(file->meta_accum+file->accum_size,0,(file->accum_buf_size-file->accum_size));
-#endif /* H5_USING_PURIFY */
+#ifdef H5_CLEAR_MEMORY
+HDmemset(file->meta_accum + file->accum_size, 0, (file->accum_buf_size - file->accum_size));
+#endif /* H5_CLEAR_MEMORY */
} /* end if */
/* Calculate the proper offset of the existing metadata */
@@ -3588,9 +3588,9 @@ HDmemset(file->meta_accum+file->accum_size,0,(file->accum_buf_size-file->accum_s
/* Reallocate the metadata accumulator buffer */
if((file->meta_accum=H5FL_BLK_REALLOC(meta_accum,file->meta_accum,file->accum_buf_size))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer")
-#ifdef H5_USING_PURIFY
-HDmemset(file->meta_accum+file->accum_size,0,(file->accum_buf_size-file->accum_size));
-#endif /* H5_USING_PURIFY */
+#ifdef H5_CLEAR_MEMORY
+HDmemset(file->meta_accum + file->accum_size, 0, (file->accum_buf_size - file->accum_size));
+#endif /* H5_CLEAR_MEMORY */
} /* end if */
/* Copy the new metadata to the end */
@@ -3625,9 +3625,12 @@ HDmemset(file->meta_accum+file->accum_size,0,(file->accum_buf_size-file->accum_s
/* Note the new buffer size */
file->accum_buf_size=size;
-#ifdef H5_USING_PURIFY
-HDmemset(file->meta_accum+file->accum_size,0,(file->accum_buf_size-file->accum_size));
-#endif /* H5_USING_PURIFY */
+#ifdef H5_CLEAR_MEMORY
+{
+size_t clear_size = MAX(file->accum_size, size);
+HDmemset(file->meta_accum + clear_size, 0, (file->accum_buf_size - clear_size));
+}
+#endif /* H5_CLEAR_MEMORY */
} /* end if */
else {
/* Check if we should shrink the accumulator buffer */
diff --git a/src/H5FDcore.c b/src/H5FDcore.c
index dba902b..4c468b6 100644
--- a/src/H5FDcore.c
+++ b/src/H5FDcore.c
@@ -826,9 +826,9 @@ H5FD_core_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, had
x = H5MM_malloc(new_eof);
else
x = H5MM_realloc(file->mem, new_eof);
-#ifdef H5_USING_PURIFY
+#ifdef H5_CLEAR_MEMORY
HDmemset(x + file->eof, 0, (size_t)(new_eof - file->eof));
-#endif /* H5_USING_PURIFY */
+#endif /* H5_CLEAR_MEMORY */
if (!x)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory block")
file->mem = x;
diff --git a/src/H5FLprivate.h b/src/H5FLprivate.h
index 4cf1d8f..1dcced6 100644
--- a/src/H5FLprivate.h
+++ b/src/H5FLprivate.h
@@ -37,7 +37,7 @@
/* Macros for turning off free lists in the library */
/*#define H5_NO_FREE_LISTS*/
-#if defined H5_NO_FREE_LISTS || defined H5_USING_PURIFY
+#if defined H5_NO_FREE_LISTS || defined H5_USING_MEMCHECKER
#define H5_NO_REG_FREE_LISTS
#define H5_NO_ARR_FREE_LISTS
#define H5_NO_SEQ_FREE_LISTS
diff --git a/src/H5Gname.c b/src/H5Gname.c
index 8a00736..7619644 100644
--- a/src/H5Gname.c
+++ b/src/H5Gname.c
@@ -392,10 +392,10 @@ H5G_name_copy(H5G_name_t *dst, const H5G_name_t *src, H5_copy_depth_t depth)
/* Check arguments */
HDassert(src);
HDassert(dst);
-#if defined(H5_USING_PURIFY) || !defined(NDEBUG)
+#if defined(H5_USING_MEMCHECKER) || !defined(NDEBUG)
HDassert(dst->full_path_r == NULL);
HDassert(dst->user_path_r == NULL);
-#endif /* H5_USING_PURIFY */
+#endif /* H5_USING_MEMCHECKER */
HDassert(depth == H5_COPY_SHALLOW || depth == H5_COPY_DEEP);
/* Copy the top level information */
diff --git a/src/H5Gnode.c b/src/H5Gnode.c
index aac96b8..6baf175 100644
--- a/src/H5Gnode.c
+++ b/src/H5Gnode.c
@@ -1604,9 +1604,9 @@ H5G_node_init(H5F_t *f)
assert(shared->sizeof_rnode);
if(NULL==(shared->page=H5FL_BLK_MALLOC(grp_page,shared->sizeof_rnode)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree page")
-#ifdef H5_USING_PURIFY
-HDmemset(shared->page,0,shared->sizeof_rnode);
-#endif /* H5_USING_PURIFY */
+#ifdef H5_CLEAR_MEMORY
+HDmemset(shared->page, 0, shared->sizeof_rnode);
+#endif /* H5_CLEAR_MEMORY */
if(NULL==(shared->nkey=H5FL_SEQ_MALLOC(size_t,(size_t)(2*H5F_KVALUE(f,H5B_SNODE)+1))))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree page")
diff --git a/src/H5Gtraverse.c b/src/H5Gtraverse.c
index 72a9d07..80d02cb 100644
--- a/src/H5Gtraverse.c
+++ b/src/H5Gtraverse.c
@@ -591,11 +591,11 @@ H5G_traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target,
obj_loc.oloc = &obj_oloc;
obj_loc.path = &obj_path;
-#if defined(H5_USING_PURIFY) || !defined(NDEBUG)
+#if defined(H5_USING_MEMCHECKER) || !defined(NDEBUG)
/* Clear group location */
if(H5G_loc_reset(&grp_loc) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to reset location")
-#endif /* H5_USING_PURIFY */
+#endif /* H5_USING_MEMCHECKER */
/* Deep copy of the starting location to group location */
if(H5G_loc_copy(&grp_loc, &loc, H5_COPY_DEEP) < 0)
diff --git a/src/H5HFdblock.c b/src/H5HFdblock.c
index 4e1c3f4..9de7bb8 100644
--- a/src/H5HFdblock.c
+++ b/src/H5HFdblock.c
@@ -144,9 +144,9 @@ H5HF_man_dblock_create(hid_t dxpl_id, H5HF_hdr_t *hdr, H5HF_indirect_t *par_iblo
/* XXX: Change to using free-list factories */
if((dblock->blk = H5FL_BLK_MALLOC(direct_block, dblock->size)) == NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
-#ifdef H5_USING_PURIFY
+#ifdef H5_CLEAR_MEMORY
HDmemset(dblock->blk, 0, dblock->size);
-#endif /* H5_USING_PURIFY */
+#endif /* H5_CLEAR_MEMORY */
/* Allocate space for the direct block on disk */
if(HADDR_UNDEF == (dblock_addr = H5MF_alloc(hdr->f, H5FD_MEM_FHEAP_DBLOCK, dxpl_id, (hsize_t)dblock->size)))
diff --git a/src/H5HG.c b/src/H5HG.c
index a2b6780..0ff9249 100644
--- a/src/H5HG.c
+++ b/src/H5HG.c
@@ -223,9 +223,9 @@ H5HG_create (H5F_t *f, hid_t dxpl_id, size_t size)
if (NULL==(heap->chunk = H5FL_BLK_MALLOC (heap_chunk,size)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, \
"memory allocation failed");
-#ifdef H5_USING_PURIFY
-HDmemset(heap->chunk,0,size);
-#endif /* H5_USING_PURIFY */
+#ifdef H5_CLEAR_MEMORY
+HDmemset(heap->chunk, 0, size);
+#endif /* H5_CLEAR_MEMORY */
heap->nalloc = H5HG_NOBJS (f, size);
heap->nused = 1; /* account for index 0, which is used for the free object */
if (NULL==(heap->obj = H5FL_SEQ_MALLOC (H5HG_obj_t,heap->nalloc)))
@@ -845,9 +845,9 @@ H5HG_extend (H5F_t *f, H5HG_heap_t *heap, size_t size, unsigned * heap_flags_ptr
/* Re-allocate the heap information in memory */
if (NULL==(new_chunk = H5FL_BLK_REALLOC (heap_chunk, heap->chunk, heap->size+need)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "new heap allocation failed");
-#ifdef H5_USING_PURIFY
-HDmemset(new_chunk+heap->size,0,need);
-#endif /* H5_USING_PURIFY */
+#ifdef H5_CLEAR_MEMORY
+HDmemset(new_chunk + heap->size, 0, need);
+#endif /* H5_CLEAR_MEMORY */
/* Adjust the size of the heap */
old_size=heap->size;
diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c
index ff0a48c..4c5d802 100644
--- a/src/H5Tcommit.c
+++ b/src/H5Tcommit.c
@@ -665,7 +665,7 @@ H5T_open(const H5G_loc_t *loc, hid_t dxpl_id)
if(NULL == (dt = H5FL_MALLOC(H5T_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate space for datatype")
-#if defined(H5_USING_PURIFY) || !defined(NDEBUG)
+#if defined(H5_USING_MEMCHECKER) || !defined(NDEBUG)
/* Clear object location */
if(H5O_loc_reset(&(dt->oloc)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to reset location")
@@ -673,7 +673,7 @@ H5T_open(const H5G_loc_t *loc, hid_t dxpl_id)
/* Clear path name */
if(H5G_name_reset(&(dt->path)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to reset path")
-#endif /* H5_USING_PURIFY */
+#endif /* H5_USING_MEMCHECKER */
/* Shallow copy (take ownership) of the object location object */
if(H5O_loc_copy(&dt->oloc, loc->oloc, H5_COPY_SHALLOW) < 0)