summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1998-06-23 03:41:22 (GMT)
committerRobb Matzke <matzke@llnl.gov>1998-06-23 03:41:22 (GMT)
commit4bf629adc96541fda24bafbdde00fd4ff92be344 (patch)
tree8e6d57995ba50bafdf172df9d480bd99cdb1230e
parent62607debf74800472572e65517ed284aef19a63c (diff)
downloadhdf5-4bf629adc96541fda24bafbdde00fd4ff92be344.zip
hdf5-4bf629adc96541fda24bafbdde00fd4ff92be344.tar.gz
hdf5-4bf629adc96541fda24bafbdde00fd4ff92be344.tar.bz2
[svn-r435] ./INSTALL
./INSTALL_MAINT ./README ./RELEASE Partially updated for second alpha, but haven't updated version numbers yet. ./src/H5.c ./src/H5A.c ./src/H5AC.c ./src/H5B.c ./src/H5D.c ./src/H5F.c ./src/H5Fcore.c ./src/H5Ffamily.c ./src/H5Fistore.c ./src/H5Fmpio.c ./src/H5Fsec2.c ./src/H5Fsplit.c ./src/H5Fstdio.c ./src/H5G.c ./src/H5Gnode.c ./src/H5HG.c ./src/H5HL.c ./src/H5I.c ./src/H5MM.c ./src/H5MMprivate.h ./src/H5O.c ./src/H5Oattr.c ./src/H5Ocomp.c ./src/H5Ocont.c ./src/H5Odtype.c ./src/H5Oefl.c ./src/H5Olayout.c ./src/H5Oname.c ./src/H5Osdspace.c ./src/H5Oshared.c ./src/H5Ostab.c ./src/H5P.c ./src/H5S.c ./src/H5T.c ./src/H5Tconv.c ./src/H5detect.c ./test/hyperslab.c ./test/istore.c Changed memory allocation functions so they fail instead of dumping core. The `x' was removed from the name to remind us of that: H5MM_xmalloc() -> H5MM_malloc(), etc. H5MM_calloc() takes one argument like H5MM_malloc() instead of two like calloc() because we almost always called it with `1' for one of the arguments anyway. The only difference between the two functions is that H5MM_calloc() returns memory which is initialized to zero. ./src/H5Gent.c ./src/H5Gprivate.h Removed H5G_ent_calloc() since it wasn't used. ./src/H5Fistore.c Fixed a bug found by Albert. Thanks, Albert! This fix combined with the changes to memory allocation prevent the library from failing an assertion if the application uses an unreasonable size for chunks (like Alberts 10000x10000x4). ./src/H5MF.c ./src/H5MFprivate.h Changed H5MF_free() to H5MF_xfree() since calling it with an undefined address is allowed.
-rw-r--r--INSTALL24
-rw-r--r--INSTALL_MAINT8
-rw-r--r--README11
-rw-r--r--RELEASE143
-rw-r--r--src/H5.c8
-rw-r--r--src/H5A.c29
-rw-r--r--src/H5AC.c39
-rw-r--r--src/H5B.c173
-rw-r--r--src/H5D.c30
-rw-r--r--src/H5Distore.c43
-rw-r--r--src/H5F.c31
-rw-r--r--src/H5Fcore.c18
-rw-r--r--src/H5Ffamily.c32
-rw-r--r--src/H5Fistore.c43
-rw-r--r--src/H5Fmpio.c5
-rw-r--r--src/H5Fsec2.c5
-rw-r--r--src/H5Fsplit.c5
-rw-r--r--src/H5Fstdio.c5
-rw-r--r--src/H5G.c25
-rw-r--r--src/H5Gent.c30
-rw-r--r--src/H5Gnode.c44
-rw-r--r--src/H5Gprivate.h1
-rw-r--r--src/H5HG.c58
-rw-r--r--src/H5HL.c90
-rw-r--r--src/H5I.c17
-rw-r--r--src/H5MF.c21
-rw-r--r--src/H5MFprivate.h2
-rw-r--r--src/H5MM.c108
-rw-r--r--src/H5MMprivate.h9
-rw-r--r--src/H5O.c145
-rw-r--r--src/H5Oattr.c27
-rw-r--r--src/H5Ocomp.c31
-rw-r--r--src/H5Ocont.c5
-rw-r--r--src/H5Odtype.c23
-rw-r--r--src/H5Oefl.c27
-rw-r--r--src/H5Olayout.c12
-rw-r--r--src/H5Oname.c18
-rw-r--r--src/H5Osdspace.c41
-rw-r--r--src/H5Oshared.c5
-rw-r--r--src/H5Ostab.c21
-rw-r--r--src/H5P.c51
-rw-r--r--src/H5S.c74
-rw-r--r--src/H5T.c109
-rw-r--r--src/H5Tconv.c32
-rw-r--r--src/H5detect.c5
-rw-r--r--test/.distdep108
-rw-r--r--test/hyperslab.c26
-rw-r--r--test/istore.c8
48 files changed, 1243 insertions, 582 deletions
diff --git a/INSTALL b/INSTALL
index 2622c5f..639e3ba 100644
--- a/INSTALL
+++ b/INSTALL
@@ -20,7 +20,8 @@ for the install may be found in the file: INSTALL.ascired.
Step 0: Install optional third-party packages.
* GNU zlib compression library, version 1.0.2 or later is used for
- the `deflate' compression method.
+ the `deflate' compression method. If libz.a cannot be found then
+ this form of compression is not compiled into the library.
Step 1. Unpack the source tree.
@@ -28,10 +29,9 @@ Step 1. Unpack the source tree.
the following commands:
$ tar xf hdf5-1.0.0a.tar OR
- $ gunzip <hdf5-1.0.0a.tar.gz |tar xf - OR
+ $ gunzip <hdf5-1.0.0a.tar.gz |tar xf - OR
$ bunzip2 <hdf5-1.0.0a.tar.bz2 |tar xf - OR
- $ uncompress -c <hdf5-1.0.0a.tar.Z | tar xf -
-
+ $ uncompress -c <hdf5-1.0.0a.tar.Z |tar xf -
Step 2. Configure makefiles.
@@ -85,6 +85,13 @@ Step 2. Configure makefiles.
name of the file is the result of running ./bin/config.guess.
Use config/BlankForm as a template.
+ * The library can print the names, arguments and values, and
+ return value from all API functions. The code that does this is
+ enabled with the `--enable-tracing' configuration switch. In
+ order to actually see tracing output one should set the
+ environment variable HDF5_TRACE to a file descriptor number such
+ as `2'.
+
* You can see a list of other configuration options by saying
$ ./configure --help
@@ -100,12 +107,6 @@ Step 3. Compile library, tests, and programs.
environment variable in the previous step then use that command
instead. The same applies below.
- Note: If you're re-building the library after changing some
- files and you're not using GNU make and gcc, then you should say
- `make clean' from the top directory between each build attempt
- since the development Makefiles don't have complete dependency
- information yet.
-
Note: When using GNU make you can add `-j -l6' to the make
command to compile in parallel on SMP machines. Do not give a
number after the `-j' since GNU make will turn it off for
@@ -117,7 +118,8 @@ Step 4. Run confidence tests.
$ make test
- The command will fail if any test fails.
+ The command will fail if any test fails, and one will see the
+ word "*FAIL*" in the output.
Note: some old versions of make will report that `test is up to
date'. If this happens then run `make _test' instead or run
diff --git a/INSTALL_MAINT b/INSTALL_MAINT
index 2d4c5c9..5066a55 100644
--- a/INSTALL_MAINT
+++ b/INSTALL_MAINT
@@ -63,6 +63,12 @@ Information for HDF5 maintainers:
GNU systems and inserted into the Makefile's by running
config.status (which happens near the end of configure).
+* If you use GNU make along with gcc then the Perl script `trace' is
+ run just before dependencies are calculated to update any H5TRACE()
+ calls that might appear in the file. Otherwise, after changing the
+ type of a function (return type or argument types) one should run
+ `trace' manually on those source files (e.g., ../bin/trace *.c).
+
* Object files stay in the directory and are added to the library as a
final step instead of placing the file in the library immediately
and removing it from the directory. The reason is three-fold:
@@ -90,4 +96,4 @@ Information for HDF5 maintainers:
$ make -j2
which limits the number of children to two (this doesn't work at the
- top level because the `-j2' is not passed to recursive makes.
+ top level because the `-j2' is not passed to recursive makes).
diff --git a/README b/README
index 9060c1b..c30f5a0 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-This is the hdf5-1.0.0a prototype release of the HDF5 library.
+This is the hdf5-1.0.0a alpha release of the HDF5 library.
This release is almost fully functional for the entire API defined in the
documentation, see the RELEASE file in this directory for information
@@ -27,12 +27,5 @@ To subscribe to a list, send mail to "<list>-request@ncsa.uiuc.edu",
address> in the _body_ of the message. Messages to be sent to
the list should be sent to "<list>@ncsa.uiuc.edu".
-Bugs should be reported to:
+Bugs should be reported to hdf5dev@ncsa.uiuc.edu.
- Robb Matzke <matzke@llnl.gov> All types of bugs
- Quincey Koziol <koziol@ncsa.uiuc.edu> All types of bugs
- Albert Cheng <acheng@ncsa.uiuc.edu> Parallel bugs
- Kim Yates <rkyates@llnl.gov> Parallel bugs
- Paul Harten <pharten@ncsa.uiuc.edu> Bugs specific to ASCI Red
-
-or to the hdf5dev mailing list.
diff --git a/RELEASE b/RELEASE
index 22c561f..09df2a6 100644
--- a/RELEASE
+++ b/RELEASE
@@ -1,58 +1,107 @@
Release information for hdf5-1.0.0a
-----------------------------------
-
-This release is an beta release for functionality necessary for the
-ASCI vector bundle project in a serial environment. Some parallel
-support is also available. Other features should be considered alpha
-quality.
+-----------------------------------
The following functions are implemented. Errors are returned if an
attempt is made to use some feature which is not implemented and
printing the error stack will show `not implemented yet'.
Library
- H5dont_atexit - don't call library close on exit
- H5init - initialize library (happens automatically)
+ H5check - check that lib version matches header version
+ H5open - initialize library (happens automatically)
+ H5close - shut down the library (happens automatically)
+ H5dont_atexit - don't call H5close on exit
H5version - retrieve library version info
-
-Templates
- H5Cclose - release template resources
- H5Ccopy - copy a template
- H5Ccreate - create a new template
- H5Cget_chunk - get chunked storage parameters
- H5Cget_class - get template class
- H5Cget_istore_k - get chunked storage parameters
- H5Cget_layout - get raw data layout class
- H5Cget_sizes - get address and size sizes
- H5Cget_sym_k - get symbol table storage parameters
- H5Cget_userblock - get user-block size
- H5Cget_version - get file version numbers
- H5Cset_chunk - set chunked storage parameters
- H5Cset_istore_k - set chunked storage parameters
- H5Cset_layout - set raw data layout class
- H5Cset_sizes - set address and size sizes
- H5Cset_sym_k - set symbol table storage parameters
- H5Cset_userblock - set user-block size
+ H5version_check - check for specific library version
+
+Property Lists
+ H5Pclose - release template resources
+ H5Pcopy - copy a template
+ H5Pcreate - create a new template
+ H5Pget_chunk - get chunked storage properties
+ H5Pset_chunk - set chunked storage properties
+ H5Pget_class - get template class
+ H5Pget_istore_k - get chunked storage properties
+ H5Pset_istore_k - set chunked storage properties
+ H5Pget_layout - get raw data layout class
+ H5Pset_layout - set raw data layout class
+ H5Pget_sizes - get address and size sizes
+ H5Pset_sizes - set address and size sizes
+ H5Pget_sym_k - get symbol table storage properties
+ H5Pset_sym_k - set symbol table storage properties
+ H5Pget_userblock - get user-block size
+ H5Pset_userblock - set user-block size
+ H5Pget_version - get file version numbers
+ H5Pget_alignment - get data alignment properties
+ H5Pset_alignment - set data alignment properties
+ H5Pget_external_count- get count of external data files
+ H5Pget_external - get information about an external data file
+ H5Pset_external - add a new external data file to the list
+ H5Pget_driver - get low-level file driver class
+ H5Pget_stdio - get properties for stdio low-level driver
+ H5Pset_stdio - set properties for stdio low-level driver
+ H5Pget_sec2 - get properties for sec2 low-level driver
+ H5Pset_sec2 - set properties for sec2 low-level driver
+ H5Pget_core - get properties for core low-level driver
+ H5Pset_core - set properties for core low-level driver
+ H5Pget_split - get properties for split low-level driver
+ H5Pset_split - set properties for split low-level driver
+ H5P_get_family - get properties for family low-level driver
+ H5P_set_family - set properties for family low-level driver
+ H5Pget_cache - get meta- and raw-data caching properties
+ H5Pset_cache - set meta- and raw-data caching properties
+ H5Pget_buffer - get raw-data I/O pipe buffer properties
+ H5Pset_buffer - set raw-data I/O pipe buffer properties
+ H5Pget_preserve - get type conversion preservation properties
+ H5Pset_preserve - set type conversion preservation properties
+ H5Pget_compression - get raw data compression properties
+ H5Pset_compression - set raw data compression properties
+ H5Pget_deflate - get deflate compression properties
+ H5Pset_deflate - set deflate compression properties
+ H5Pget_mpi - get MPI-IO properties
+ H5Pset_mpi - set MPI-IO properties
+ H5Pget_xfer - get data transfer properties
+ H5Pset_xfer - set data transfer properties
Datasets
H5Dclose - release dataset resources
H5Dcreate - create a new dataset
H5Dget_space - get data space
+ H5Dget_type - get data type
+ H5Dget_create_plist - get dataset creation properties
H5Dopen - open an existing dataset
H5Dread - read raw data
H5Dwrite - write raw data
+ H5Dextend - extend a dataset
+
+Attributes
+ H5Acreate - create a new attribute
+ H5Aopen_name - open an attribute by name
+ H5Aopen_idx - open an attribute by number
+ H5Awrite - write values into an attribute
+ H5Aread - read values from an attribute
+ H5Aget_space - get attribute data space
+ H5Aget_type - get attribute data type
+ H5Aget_name - get attribute name
+ H5Anum_attrs - return the number of attributes for an object
+ H5Aiterate - iterate over an object's attributes
+ H5Adelete - delete an attribute
+ H5Aclose - close an attribute
Errors
H5Eclear - clear the error stack
- H5Eclose - release an error stack
- H5Ecreate - create a new error stack
H5Eprint - print an error stack
- H5Epush - push an error onto a stack
+ H5Eget_auto - get automatic error reporting settings
+ H5Eset_auto - set automatic error reporting
+ H5Ewalk - iterate over the error stack
+ H5Ewalk_cb - the default error stack iterator function
+ H5Eget_major - get the message for the major error number
+ H5Eget_minor - get the message for the minor error number
Files
H5Fclose - close a file and release resources
H5Fcreate - create a new file
- H5Fget_create_template - get file creation template
+ H5Fget_create_template- get file creation property list
+ H5Fget_access_template- get file access property list
H5Fis_hdf5 - determine if a file is an hdf5 file
H5Fopen - open an existing file
@@ -63,24 +112,35 @@ Groups
H5Gpop - pop a group from the cwg stack
H5Gpush - push a group onto the cwg stack
H5Gset - set the current working group (cwg)
+ H5Giterate - iterate over the contents of a group
+ H5Gmove - change the name of some object
+ H5Glink - create a hard or soft link to an object
+ H5Gunlink - break the link between a name and an object
+ H5Gstat - get information about a group entry
+ H5Gget_linkval - get the value of a soft link
Data spaces
- H5Pclose - release data space resources
- H5Pcreate_simple - create a new simple data space
- H5Pget_dims - get data space size
- H5Pget_hyperslab - get data space selection
- H5Pget_ndims - get data space dimensionality
- H5Pget_npoints - get number of selected points
- H5Pis_simple - determine if data space is simple
- H5Pset_hyperslab - select data points
- H5Pset_space - reset data space dimensionality and size
+ H5Sclose - release data space resources
+ H5Screate_simple - create a new simple data space
+ H5Sget_dims - get data space size
+ H5Sget_hyperslab - get data space selection
+ H5Sset_hyperslab - select data points
+ H5Sget_ndims - get data space dimensionality
+ H5Sget_npoints - get number of selected points
+ H5Sis_simple - determine if data space is simple
+ H5Sset_space - reset data space dimensionality and size
+ H5Scopy - copy a data space
Data types
H5Tclose - release data type resources
+ H5Topen - open a named data type
+ H5Tcommit - name a data type
+ H5Tcommitted - determine if a type is named
H5Tcopy - copy a data type
H5Tcreate - create a new data type
H5Tequal - compare two data types
H5Tfind - find a data type conversion function
+ H5Tconvert - convert data from one type to another
H5Tget_class - get data type class
H5Tget_cset - get character set
H5Tget_ebias - get exponent bias
@@ -118,6 +178,9 @@ Data types
H5Tset_strpad - set string padding
H5Tunregister - remove a type conversion function
+Compression
+ H5Tregister - register a new compression method
+
This release has been tested on UNIX platforms only; specifically:
Linux, FreedBSD, IRIX, Solaris & Dec UNIX.
diff --git a/src/H5.c b/src/H5.c
index 3372250..71defe7 100644
--- a/src/H5.c
+++ b/src/H5.c
@@ -140,20 +140,22 @@ H5_init_library(void)
herr_t
H5_add_exit(void (*func) (void))
{
- herr_t ret_value = SUCCEED;
H5_exit_t *new_exit;
FUNC_ENTER_INIT(H5_add_exit, NULL, FAIL);
assert(func);
- new_exit = H5MM_xcalloc(1, sizeof(H5_exit_t));
+ if (NULL==(new_exit = H5MM_calloc(sizeof(H5_exit_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
new_exit->func = func;
new_exit->next = lib_exit_head;
lib_exit_head = new_exit;
- FUNC_LEAVE(ret_value);
+ FUNC_LEAVE(SUCCEED);
} /* end H5_add_exit() */
/*--------------------------------------------------------------------------
diff --git a/src/H5A.c b/src/H5A.c
index 9a12ffb..d7014b6 100644
--- a/src/H5A.c
+++ b/src/H5A.c
@@ -253,9 +253,9 @@ H5A_create(const H5G_entry_t *ent, const char *name, const H5T_t *type,
assert(space);
/* Build the attribute information */
- if((attr = H5MM_xcalloc(1, sizeof(H5A_t)))==NULL)
+ if((attr = H5MM_calloc(sizeof(H5A_t)))==NULL)
HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "unable to allocate space for attribute info");
+ "memory allocation failed for attribute info");
attr->name=HDstrdup(name);
attr->dt=H5T_copy(type, H5T_COPY_ALL);
attr->ds=H5S_copy(space);
@@ -680,7 +680,10 @@ H5A_write(H5A_t *attr, const H5T_t *mem_type, void *buf)
/* Get the maximum buffer size needed and allocate it */
buf_size = nelmts*MAX(src_type_size,dst_type_size);
- tconv_buf = H5MM_xmalloc (buf_size);
+ if (NULL==(tconv_buf = H5MM_malloc (buf_size))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
/* Copy the user's data into the buffer for conversion */
HDmemcpy(tconv_buf,buf,src_type_size*nelmts);
@@ -847,7 +850,10 @@ H5A_read(H5A_t *attr, const H5T_t *mem_type, void *buf)
/* Get the maximum buffer size needed and allocate it */
buf_size = nelmts*MAX(src_type_size,dst_type_size);
- tconv_buf = H5MM_xmalloc (buf_size);
+ if (NULL==(tconv_buf = H5MM_malloc (buf_size))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
/* Copy the attribute data into the buffer for conversion */
HDmemcpy(tconv_buf,attr->data,src_type_size*nelmts);
@@ -1396,7 +1402,10 @@ H5A_copy(const H5A_t *old_attr)
assert(old_attr);
/* get space */
- new_attr = H5MM_xcalloc(1, sizeof(H5A_t));
+ if (NULL==(new_attr = H5MM_calloc(sizeof(H5A_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
/* Copy the top level of the attribute */
*new_attr = *old_attr;
@@ -1409,7 +1418,10 @@ H5A_copy(const H5A_t *old_attr)
new_attr->dt=H5T_copy(old_attr->dt, H5T_COPY_ALL);
new_attr->ds=H5S_copy(old_attr->ds);
if(old_attr->data) {
- new_attr->data=H5MM_xmalloc(old_attr->data_size);
+ if (NULL==(new_attr->data=H5MM_malloc(old_attr->data_size))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
HDmemcpy(new_attr->data,old_attr->data,old_attr->data_size);
} /* end if */
@@ -1446,11 +1458,10 @@ H5A_close(H5A_t *attr)
/* Check if the attribute has any data yet, if not, fill with zeroes */
if(attr->ent_opened && !attr->initialized) {
- uint8 *tmp_buf=H5MM_xcalloc(1,attr->data_size);
-
+ uint8 *tmp_buf=H5MM_calloc(attr->data_size);
if (NULL == tmp_buf) {
HRETURN_ERROR(H5E_ATTR, H5E_NOSPACE, FAIL,
- "unable to allocate attribute fill-value");
+ "memory allocation failed for attribute fill-value");
}
/* Go write the fill data to the attribute */
diff --git a/src/H5AC.c b/src/H5AC.c
index 986b35b..0e4b325 100644
--- a/src/H5AC.c
+++ b/src/H5AC.c
@@ -72,9 +72,17 @@ H5AC_create(H5F_t *f, intn size_hint)
assert(NULL == f->shared->cache);
if (size_hint < 1) size_hint = H5AC_NSLOTS;
- f->shared->cache = cache = H5MM_xcalloc(1, sizeof(H5AC_t));
+ if (NULL==(f->shared->cache = cache = H5MM_calloc(sizeof(H5AC_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
cache->nslots = size_hint;
- cache->slot = H5MM_xcalloc((intn)(cache->nslots), sizeof(H5AC_slot_t));
+ cache->slot = H5MM_calloc(cache->nslots*sizeof(H5AC_slot_t));
+ if (NULL==cache->slot) {
+ f->shared->cache = H5MM_xfree (f->shared->cache);
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
FUNC_LEAVE(size_hint);
}
@@ -360,7 +368,10 @@ H5AC_flush(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
* Sort the cache entries by address since flushing them in
* ascending order by address may be much more efficient.
*/
- map = H5MM_xmalloc(cache->nslots * sizeof(intn));
+ if (NULL==(map=H5MM_malloc(cache->nslots * sizeof(intn)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
for (i = nslots = 0; i < cache->nslots; i++) {
if (cache->slot[i].type)
map[nslots++] = i;
@@ -427,7 +438,7 @@ H5AC_flush(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
cache->slot[i].thing);
if (status < 0) {
HRETURN_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL,
- "can't flush object");
+ "unable to flush object");
}
cache->diagnostics[cache->slot[i].type->id].nflushes++;
if (destroy)
@@ -496,7 +507,7 @@ H5AC_set(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr, void *thing)
status = (flush) (f, TRUE, &(slot->addr), slot->thing);
if (status < 0) {
HRETURN_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL,
- "can't flush object");
+ "unable to flush object");
}
cache->diagnostics[slot->type->id].nflushes++;
}
@@ -587,7 +598,7 @@ H5AC_rename(H5F_t *f, const H5AC_class_t *type,
cache->slot[new_idx].thing);
if (status < 0) {
HRETURN_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL,
- "can't flush object");
+ "unable to flush object");
}
cache->diagnostics[cache->slot[new_idx].type->id].nflushes++;
}
@@ -694,7 +705,7 @@ H5AC_protect(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
cache->diagnostics[type->id].nmisses++;
if (NULL == (thing = (type->load) (f, addr, udata1, udata2))) {
HRETURN_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL,
- "can't load object");
+ "unable to load object");
}
}
@@ -704,9 +715,15 @@ H5AC_protect(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
* cache.
*/
if (slot->nprots >= slot->aprots) {
- slot->aprots += 10;
- slot->prot = H5MM_xrealloc(slot->prot,
- slot->aprots * sizeof(H5AC_prot_t));
+ size_t na = slot->aprots + 10;
+ H5AC_prot_t *x = H5MM_realloc(slot->prot,
+ na * sizeof(H5AC_prot_t));
+ if (NULL==x) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
+ slot->aprots = na;
+ slot->prot = x;
}
slot->prot[slot->nprots].type = type;
slot->prot[slot->nprots].addr = *addr;
@@ -776,7 +793,7 @@ H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
status = (flush) (f, TRUE, &(slot->addr), slot->thing);
if (status < 0) {
HRETURN_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL,
- "can't flush object");
+ "unable to flush object");
}
cache->diagnostics[slot->type->id].nflushes++;
}
diff --git a/src/H5B.c b/src/H5B.c
index 9ba878e..b219b17 100644
--- a/src/H5B.c
+++ b/src/H5B.c
@@ -160,13 +160,15 @@ static hbool_t interface_initialize_g = FALSE;
*-------------------------------------------------------------------------
*/
herr_t
-H5B_create(H5F_t *f, const H5B_class_t *type, void *udata, haddr_t *retval)
+H5B_create(H5F_t *f, const H5B_class_t *type, void *udata,
+ haddr_t *addr/*out*/)
{
- H5B_t *bt = NULL;
- size_t size, sizeof_rkey;
- size_t total_native_keysize;
- size_t offset;
- intn i;
+ H5B_t *bt = NULL;
+ size_t size, sizeof_rkey;
+ size_t total_native_keysize;
+ size_t offset;
+ intn i;
+ herr_t ret_value = FAIL;
FUNC_ENTER(H5B_create, FAIL);
@@ -175,18 +177,22 @@ H5B_create(H5F_t *f, const H5B_class_t *type, void *udata, haddr_t *retval)
*/
assert(f);
assert(type);
- assert(retval);
+ assert(addr);
/*
* Allocate file and memory data structures.
*/
sizeof_rkey = (type->get_sizeof_rkey) (f, udata);
size = H5B_nodesize(f, type, &total_native_keysize, sizeof_rkey);
- if (H5MF_alloc(f, H5MF_META, (hsize_t)size, retval) < 0) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "can't allocate file space for B-tree root node");
+ if (H5MF_alloc(f, H5MF_META, (hsize_t)size, addr/*out*/) < 0) {
+ H5F_addr_undef (addr);
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "file allocation failed for B-tree root node");
+ }
+ if (NULL==(bt = H5MM_calloc(sizeof(H5B_t)))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed for B-tree root node");
}
- bt = H5MM_xmalloc(sizeof(H5B_t));
bt->type = type;
bt->sizeof_rkey = sizeof_rkey;
bt->dirty = TRUE;
@@ -196,10 +202,13 @@ H5B_create(H5F_t *f, const H5B_class_t *type, void *udata, haddr_t *retval)
H5F_addr_undef(&(bt->left));
H5F_addr_undef(&(bt->right));
bt->nchildren = 0;
- bt->page = H5MM_xcalloc(1, size); /*use calloc() to keep file clean */
- bt->native = H5MM_xmalloc(total_native_keysize);
- bt->child = H5MM_xmalloc(2 * H5B_K(f, type) * sizeof(haddr_t));
- bt->key = H5MM_xmalloc((2 * H5B_K(f, type) + 1) * sizeof(H5B_key_t));
+ if (NULL==(bt->page=H5MM_calloc(size)) ||
+ NULL==(bt->native=H5MM_malloc(total_native_keysize)) ||
+ NULL==(bt->child=H5MM_malloc(2*H5B_K(f,type)*sizeof(haddr_t))) ||
+ NULL==(bt->key=H5MM_malloc((2*H5B_K(f,type)+1)*sizeof(H5B_key_t)))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed for B-tree root node");
+ }
/*
* Initialize each entry's raw child and key pointers to point into the
@@ -226,14 +235,28 @@ H5B_create(H5F_t *f, const H5B_class_t *type, void *udata, haddr_t *retval)
/*
* Cache the new B-tree node.
*/
- if (H5AC_set(f, H5AC_BT, retval, bt) < 0) {
+ if (H5AC_set(f, H5AC_BT, addr, bt) < 0) {
HRETURN_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL,
"can't add B-tree root node to cache");
}
#ifdef H5B_DEBUG
- H5B_assert(f, retval, type, udata);
+ H5B_assert(f, addr, type, udata);
#endif
- FUNC_LEAVE(SUCCEED);
+ ret_value = SUCCEED;
+
+ done:
+ if (ret_value<0) {
+ H5MF_xfree (f, addr, (hsize_t)size);
+ if (bt) {
+ H5MM_xfree (bt->page);
+ H5MM_xfree (bt->native);
+ H5MM_xfree (bt->child);
+ H5MM_xfree (bt->key);
+ H5MM_xfree (bt);
+ }
+ }
+
+ FUNC_LEAVE(ret_value);
}
/*-------------------------------------------------------------------------
@@ -271,18 +294,24 @@ H5B_load(H5F_t *f, const haddr_t *addr, const void *_type, void *udata)
assert(type);
assert(type->get_sizeof_rkey);
- bt = H5MM_xmalloc(sizeof(H5B_t));
+ if (NULL==(bt = H5MM_calloc(sizeof(H5B_t)))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
bt->sizeof_rkey = (type->get_sizeof_rkey) (f, udata);
size = H5B_nodesize(f, type, &total_nkey_size, bt->sizeof_rkey);
bt->type = type;
bt->dirty = FALSE;
bt->ndirty = 0;
- bt->page = H5MM_xmalloc(size);
- bt->native = H5MM_xmalloc(total_nkey_size);
- bt->key = H5MM_xmalloc((2 * H5B_K(f, type) + 1) * sizeof(H5B_key_t));
- bt->child = H5MM_xmalloc(2 * H5B_K(f, type) * sizeof(haddr_t));
+ if (NULL==(bt->page=H5MM_malloc(size)) ||
+ NULL==(bt->native=H5MM_malloc(total_nkey_size)) ||
+ NULL==(bt->key=H5MM_malloc((2*H5B_K(f,type)+1)*sizeof(H5B_key_t))) ||
+ NULL==(bt->child=H5MM_malloc(2*H5B_K(f,type)*sizeof(haddr_t)))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
if (H5F_block_read(f, addr, (hsize_t)size, H5D_XFER_DFLT, bt->page) < 0) {
- HRETURN_ERROR(H5E_BTREE, H5E_READERROR, NULL,
+ HGOTO_ERROR(H5E_BTREE, H5E_READERROR, NULL,
"can't read B-tree node");
}
p = bt->page;
@@ -765,8 +794,9 @@ H5B_insert(H5F_t *f, const H5B_class_t *type, const haddr_t *addr,
intn level;
H5B_t *bt;
size_t size;
- uint8 *buf;
+ uint8 *buf = NULL;
H5B_ins_t my_ins = H5B_INS_ERROR;
+ herr_t ret_value = FAIL;
FUNC_ENTER(H5B_insert, FAIL);
@@ -781,80 +811,83 @@ H5B_insert(H5F_t *f, const H5B_class_t *type, const haddr_t *addr,
if ((my_ins = H5B_insert_helper(f, addr, type, lt_key, &lt_key_changed,
md_key, udata, rt_key, &rt_key_changed,
&child/*out*/ )) < 0 || my_ins < 0) {
- HRETURN_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL,
- "unable to insert key");
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL,
+ "unable to insert key");
}
- if (H5B_INS_NOOP == my_ins)
- HRETURN(SUCCEED);
+ if (H5B_INS_NOOP == my_ins) HRETURN(SUCCEED);
assert(H5B_INS_RIGHT == my_ins);
/* the current root */
if (NULL == (bt = H5AC_find(f, H5AC_BT, addr, type, udata))) {
- HRETURN_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
- "unable to locate root of B-tree");
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
+ "unable to locate root of B-tree");
}
level = bt->level;
if (!lt_key_changed) {
if (!bt->key[0].nkey && H5B_decode_key(f, bt, 0) < 0) {
- HRETURN_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL,
- "unable to decode key");
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL,
+ "unable to decode key");
}
HDmemcpy(lt_key, bt->key[0].nkey, type->sizeof_nkey);
}
+
/* the new node */
if (NULL == (bt = H5AC_find(f, H5AC_BT, &child, type, udata))) {
- HRETURN_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
- "unable to load new node");
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
+ "unable to load new node");
}
if (!rt_key_changed) {
if (!bt->key[bt->nchildren].nkey &&
H5B_decode_key(f, bt, bt->nchildren) < 0) {
- HRETURN_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL,
- "unable to decode key");
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL,
+ "unable to decode key");
}
HDmemcpy(rt_key, bt->key[bt->nchildren].nkey, type->sizeof_nkey);
}
+
/*
* Copy the old root node to some other file location and make the new
* root at the old root's previous address. This prevents the B-tree
* from "moving".
*/
size = H5B_nodesize(f, type, NULL, bt->sizeof_rkey);
- buf = H5MM_xmalloc(size);
+ if (NULL==(buf = H5MM_malloc(size))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
if (H5MF_alloc(f, H5MF_META, (hsize_t)size, &old_root/*out*/) < 0) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "unable to allocate file space to move root");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "unable to allocate file space to move root");
}
if (H5AC_flush(f, H5AC_BT, addr, FALSE) < 0) {
- HRETURN_ERROR(H5E_BTREE, H5E_CANTFLUSH, FAIL,
- "unable to flush B-tree root node");
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTFLUSH, FAIL,
+ "unable to flush B-tree root node");
}
if (H5F_block_read(f, addr, (hsize_t)size, H5D_XFER_DFLT, buf) < 0) {
- HRETURN_ERROR(H5E_BTREE, H5E_READERROR, FAIL,
- "unable to read B-tree root node");
+ HGOTO_ERROR(H5E_BTREE, H5E_READERROR, FAIL,
+ "unable to read B-tree root node");
}
if (H5F_block_write(f, &old_root, (hsize_t)size, H5D_XFER_DFLT, buf) < 0) {
- HRETURN_ERROR(H5E_BTREE, H5E_WRITEERROR, FAIL,
- "unable to move B-tree root node");
+ HGOTO_ERROR(H5E_BTREE, H5E_WRITEERROR, FAIL,
+ "unable to move B-tree root node");
}
if (H5AC_rename(f, H5AC_BT, addr, &old_root) < 0) {
- HRETURN_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL,
- "unable to move B-tree root node");
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL,
+ "unable to move B-tree root node");
}
- buf = H5MM_xfree(buf);
/* update the new child's left pointer */
if (NULL == (bt = H5AC_find(f, H5AC_BT, &child, type, udata))) {
- HRETURN_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
- "unable to load new child");
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
+ "unable to load new child");
}
bt->dirty = TRUE;
bt->left = old_root;
/* clear the old root at the old address (we already copied it) */
if (NULL == (bt = H5AC_find(f, H5AC_BT, addr, type, udata))) {
- HRETURN_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
- "unable to clear old root location");
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
+ "unable to clear old root location");
}
bt->dirty = TRUE;
bt->ndirty = 0;
@@ -864,8 +897,7 @@ H5B_insert(H5F_t *f, const H5B_class_t *type, const haddr_t *addr,
/* the new root */
if (NULL == (bt = H5AC_find(f, H5AC_BT, addr, type, udata))) {
- HRETURN_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
- "unable to load new root");
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load new root");
}
bt->dirty = TRUE;
bt->ndirty = 2;
@@ -889,8 +921,13 @@ H5B_insert(H5F_t *f, const H5B_class_t *type, const haddr_t *addr,
#ifdef H5B_DEBUG
H5B_assert(f, addr, type, udata);
#endif
- FUNC_LEAVE(SUCCEED);
+ ret_value = SUCCEED;
+
+ done:
+ buf = H5MM_xfree(buf);
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5B_insert_child
@@ -1403,14 +1440,14 @@ H5B_iterate (H5F_t *f, const H5B_class_t *type, const haddr_t *addr,
assert(udata);
if (NULL == (bt = H5AC_find(f, H5AC_BT, addr, type, udata))) {
- HRETURN_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
- "unable to load B-tree node");
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
+ "unable to load B-tree node");
}
if (bt->level > 0) {
/* Keep following the left-most child until we reach a leaf node. */
if (H5B_iterate(f, type, bt->child + 0, udata) < 0) {
- HRETURN_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL,
- "unable to list B-tree node");
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL,
+ "unable to list B-tree node");
} else {
HRETURN(SUCCEED);
}
@@ -1419,7 +1456,10 @@ H5B_iterate (H5F_t *f, const H5B_class_t *type, const haddr_t *addr,
* We've reached the left-most leaf. Now follow the right-sibling
* pointer from leaf to leaf until we've processed all leaves.
*/
- child = H5MM_xmalloc (2*H5B_K(f,type)*sizeof(haddr_t));
+ if (NULL==(child = H5MM_malloc (2*H5B_K(f,type)*sizeof(haddr_t)))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
for (cur_addr=addr, ret_value=0;
H5F_addr_defined(cur_addr);
cur_addr=&next_addr) {
@@ -1431,7 +1471,10 @@ H5B_iterate (H5F_t *f, const H5B_class_t *type, const haddr_t *addr,
if (NULL==(bt=H5AC_find (f, H5AC_BT, cur_addr, type, udata))) {
HGOTO_ERROR (H5E_BTREE, H5E_CANTLOAD, FAIL, "B-tree node");
}
- child = H5MM_xmalloc (bt->nchildren*sizeof(haddr_t));
+ if (NULL==(child=H5MM_malloc (bt->nchildren*sizeof(haddr_t)))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
for (i=0; i<bt->nchildren; i++) {
child[i] = bt->child[i];
}
@@ -1647,7 +1690,8 @@ H5B_assert(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
/* Initialize the queue */
bt = H5AC_find(f, H5AC_BT, addr, type, udata);
assert(bt);
- cur = H5MM_xcalloc(1, sizeof(struct child_t));
+ cur = H5MM_calloc(sizeof(struct child_t));
+ assert (cur);
cur->addr = *addr;
cur->level = bt->level;
head = tail = cur;
@@ -1688,7 +1732,8 @@ H5B_assert(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
}
/* Add the child node to the end of the queue */
- tmp = H5MM_xcalloc(1, sizeof(struct child_t));
+ tmp = H5MM_calloc(sizeof(struct child_t));
+ assert (tmp);
tmp->addr = bt->child[i];
tmp->level = bt->level - 1;
tail->next = tmp;
diff --git a/src/H5D.c b/src/H5D.c
index b33d38a..d696f92 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -783,7 +783,10 @@ H5D_create(H5G_t *loc, const char *name, const H5T_t *type, const H5S_t *space,
}
/* Initialize the dataset object */
- new_dset = H5MM_xcalloc(1, sizeof(H5D_t));
+ if (NULL==(new_dset = H5MM_calloc(sizeof(H5D_t)))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
H5F_addr_undef(&(new_dset->ent.header));
new_dset->type = H5T_copy(type, H5T_COPY_ALL);
new_dset->create_parms = H5P_copy (H5P_DATASET_CREATE, create_parms);
@@ -978,7 +981,10 @@ H5D_open(H5G_t *loc, const char *name)
assert (name && *name);
f = H5G_fileof (loc);
- dataset = H5MM_xcalloc(1, sizeof(H5D_t));
+ if (NULL==(dataset = H5MM_calloc(sizeof(H5D_t)))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
dataset->create_parms = H5P_copy (H5P_DATASET_CREATE, &H5D_create_dflt);
H5F_addr_undef(&(dataset->ent.header));
@@ -1316,10 +1322,16 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
need_bkg = H5T_BKG_NO; /*never needed even if app says yes*/
}
if (NULL==(tconv_buf=xfer_parms->tconv_buf)) {
- tconv_buf = H5MM_xmalloc (target_size);
+ if (NULL==(tconv_buf = H5MM_malloc (target_size))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed for type conversion");
+ }
}
if (need_bkg && NULL==(bkg_buf=xfer_parms->bkg_buf)) {
- bkg_buf = H5MM_xmalloc (smine_nelmts * dst_type_size);
+ if (NULL==(bkg_buf = H5MM_malloc (smine_nelmts * dst_type_size))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed for background buffer");
+ }
}
#ifdef H5D_DEBUG
@@ -1604,10 +1616,16 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
need_bkg = H5T_BKG_NO; /*never needed even if app says yes*/
}
if (NULL==(tconv_buf=xfer_parms->tconv_buf)) {
- tconv_buf = H5MM_xmalloc (target_size);
+ if (NULL==(tconv_buf = H5MM_malloc (target_size))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed for type conversion");
+ }
}
if (need_bkg && NULL==(bkg_buf=xfer_parms->bkg_buf)) {
- bkg_buf = H5MM_xmalloc (smine_nelmts * dst_type_size);
+ if (NULL==(bkg_buf = H5MM_malloc (smine_nelmts * dst_type_size))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed for background buffer");
+ }
}
#ifdef H5D_DEBUG
diff --git a/src/H5Distore.c b/src/H5Distore.c
index de6a1cb..2f23715 100644
--- a/src/H5Distore.c
+++ b/src/H5Distore.c
@@ -645,7 +645,11 @@ H5F_istore_init (H5F_t *f)
HDmemset (rdcc, 0, sizeof(H5F_rdcc_t));
if (f->shared->access_parms->rdcc_nbytes>0) {
rdcc->nslots = 25; /*some initial number of slots*/
- rdcc->slot = H5MM_xcalloc (rdcc->nslots, sizeof(H5F_rdcc_ent_t));
+ rdcc->slot = H5MM_calloc (rdcc->nslots*sizeof(H5F_rdcc_ent_t));
+ if (NULL==rdcc->slot) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
}
FUNC_LEAVE (SUCCEED);
@@ -685,7 +689,10 @@ H5F_istore_flush_entry (H5F_t *f, H5F_rdcc_ent_t *ent)
/* Should the chunk be compressed before writing it to disk? */
if (ent->comp && H5Z_NONE!=ent->comp->method) {
- c_buf = H5MM_xmalloc (ent->chunk_size);
+ if (NULL==(c_buf = H5MM_malloc (ent->chunk_size))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed for data compression");
+ }
nbytes = H5Z_compress (ent->comp, ent->chunk_size, ent->chunk, c_buf);
if (nbytes && nbytes<ent->chunk_size) {
out_ptr = c_buf;
@@ -1004,7 +1011,10 @@ H5F_istore_lock (H5F_t *f, const H5O_layout_t *layout,
for (i=0, chunk_size=1; i<layout->ndims; i++) {
chunk_size *= layout->dim[i];
}
- chunk = H5MM_xmalloc (chunk_size);
+ if (NULL==(chunk=H5MM_malloc (chunk_size))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed for raw data chunk");
+ }
} else {
/*
@@ -1018,7 +1028,11 @@ H5F_istore_lock (H5F_t *f, const H5O_layout_t *layout,
udata.mesg = *layout;
H5F_addr_undef (&(udata.addr));
status = H5B_find (f, H5B_ISTORE, &(layout->addr), &udata);
- chunk = H5MM_xmalloc (chunk_size);
+ H5E_clear ();
+ if (NULL==(chunk = H5MM_malloc (chunk_size))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed for raw data chunk");
+ }
if (status>=0 && H5F_addr_defined (&(udata.addr))) {
/*
* The chunk exists on disk but might be compressed. Instead of
@@ -1032,7 +1046,10 @@ H5F_istore_lock (H5F_t *f, const H5O_layout_t *layout,
"unable to read raw data chunk");
}
if (udata.key.nbytes<chunk_size) {
- temp = H5MM_xmalloc (chunk_size);
+ if (NULL==(temp = H5MM_malloc (chunk_size))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed for uncompress");
+ }
if (chunk_size!=H5Z_uncompress (comp, udata.key.nbytes,
chunk, chunk_size, temp)) {
HGOTO_ERROR (H5E_IO, H5E_READERROR, NULL,
@@ -1062,10 +1079,15 @@ H5F_istore_lock (H5F_t *f, const H5O_layout_t *layout,
H5E_clear ();
}
if (rdcc->nused>=rdcc->nslots) {
- rdcc->nslots = MAX (25, 2*rdcc->nslots);
- rdcc->slot = H5MM_xrealloc (rdcc->slot,
- (rdcc->nslots*
- sizeof(H5F_rdcc_ent_t)));
+ size_t na = MAX (25, 2*rdcc->nslots);
+ H5F_rdcc_ent_t *x = H5MM_realloc (rdcc->slot,
+ na*sizeof(H5F_rdcc_ent_t));
+ if (NULL==x) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
+ rdcc->nslots = na;
+ rdcc->slot = x;
}
HDmemmove (rdcc->slot+1, rdcc->slot,
rdcc->nused*sizeof(H5F_rdcc_ent_t));
@@ -1182,8 +1204,9 @@ H5F_istore_unlock (H5F_t *f, const H5O_layout_t *layout,
x.dirty = TRUE;
x.layout = H5O_copy (H5O_LAYOUT, layout);
x.comp = H5O_copy (H5O_COMPRESS, comp);
- for (i=0; i<layout->ndims; i++) {
+ for (i=0, x.chunk_size=1; i<layout->ndims; i++) {
x.offset[i] = offset[i];
+ x.chunk_size *= layout->dim[i];
}
x.chunk = chunk;
H5F_istore_flush_entry (f, &x);
diff --git a/src/H5F.c b/src/H5F.c
index 6065d5d..e209993 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -496,25 +496,29 @@ H5Fis_hdf5 (const char *filename)
static H5F_t *
H5F_new(H5F_file_t *shared, const H5F_create_t *fcpl, const H5F_access_t *fapl)
{
- H5F_t *f = NULL;
+ H5F_t *f=NULL, *ret_value=NULL;
intn n;
FUNC_ENTER(H5F_new, NULL);
- f = H5MM_xcalloc(1, sizeof(H5F_t));
- f->shared = shared;
+ if (NULL==(f = H5MM_calloc(sizeof(H5F_t)))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
- if (!f->shared) {
- f->shared = H5MM_xcalloc(1, sizeof(H5F_file_t));
+ if (shared) {
+ f->shared = shared;
+ } else {
+ f->shared = H5MM_calloc(sizeof(H5F_file_t));
H5F_addr_undef(&(f->shared->boot_addr));
H5F_addr_undef(&(f->shared->base_addr));
H5F_addr_undef(&(f->shared->freespace_addr));
H5F_addr_undef(&(f->shared->hdf5_eof));
-
+
/*
- * Deep-copy the file creation and file access property lists into
- * the new file handle. We do this early because some values might
- * need to change as the file is being opened.
+ * Deep-copy the file creation and file access property lists into the
+ * new file handle. We do this early because some values might need
+ * to change as the file is being opened.
*/
if (NULL==(f->shared->create_parms=H5P_copy(H5P_FILE_CREATE, fcpl))) {
HRETURN_ERROR (H5E_FILE, H5E_CANTINIT, NULL,
@@ -540,8 +544,15 @@ H5F_new(H5F_file_t *shared, const H5F_create_t *fcpl, const H5F_access_t *fapl)
H5F_istore_init (f);
}
f->shared->nrefs++;
+ ret_value = f;
- FUNC_LEAVE(f);
+ done:
+ if (!ret_value && f) {
+ if (!shared) H5MM_xfree (f->shared);
+ H5MM_xfree (f);
+ }
+
+ FUNC_LEAVE(ret_value);
}
diff --git a/src/H5Fcore.c b/src/H5Fcore.c
index c0bfbf7..f87f436 100644
--- a/src/H5Fcore.c
+++ b/src/H5Fcore.c
@@ -117,7 +117,10 @@ H5F_core_open(const char __unused__ *name,
"must creat file with write access");
}
- lf = H5MM_xcalloc(1, sizeof(H5F_low_t));
+ if (NULL==(lf = H5MM_calloc(sizeof(H5F_low_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
lf->u.core.mem = NULL;
lf->u.core.alloc = 0;
lf->u.core.size = 0;
@@ -240,9 +243,9 @@ H5F_core_write(H5F_low_t *lf, const H5F_access_t *access_parms,
const H5D_transfer_t __unused__ xfer_mode,
const haddr_t *addr, size_t size, const uint8 *buf)
{
- size_t need_more;
+ size_t need_more, na;
size_t increment = 1;
-
+ uint8 *x = NULL;
FUNC_ENTER(H5F_core_write, FAIL);
@@ -261,8 +264,13 @@ H5F_core_write(H5F_low_t *lf, const H5F_access_t *access_parms,
need_more = addr->offset+size - lf->u.core.alloc;
need_more = increment*((need_more+increment-1)/increment);
- lf->u.core.alloc = lf->u.core.alloc + need_more;
- lf->u.core.mem = H5MM_xrealloc(lf->u.core.mem, lf->u.core.alloc);
+ na = lf->u.core.alloc + need_more;
+ if (NULL==(x = H5MM_realloc (lf->u.core.mem, na))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
+ lf->u.core.alloc = na;
+ lf->u.core.mem = x;
}
/* Move the physical EOF marker */
diff --git a/src/H5Ffamily.c b/src/H5Ffamily.c
index 01b5682..bed381f 100644
--- a/src/H5Ffamily.c
+++ b/src/H5Ffamily.c
@@ -124,8 +124,11 @@ H5F_fam_open(const char *name, const H5F_access_t *access_parms,
}
/* Create the file descriptor */
- lf = H5MM_xcalloc(1, sizeof(H5F_low_t));
- lf->u.fam.name = H5MM_xstrdup(name);
+ if (NULL==(lf = H5MM_calloc(sizeof(H5F_low_t))) ||
+ NULL==(lf->u.fam.name = H5MM_strdup(name))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
lf->u.fam.flags = (flags & ~H5F_ACC_CREAT);
/* Open all existing members */
@@ -151,9 +154,15 @@ H5F_fam_open(const char *name, const H5F_access_t *access_parms,
/* Add the member to the family */
if (lf->u.fam.nmemb >= lf->u.fam.nalloc) {
- lf->u.fam.nalloc = MAX(100, 2 * lf->u.fam.nalloc);
- lf->u.fam.memb = H5MM_xrealloc(lf->u.fam.memb,
- lf->u.fam.nalloc * sizeof(H5F_low_t *));
+ size_t na = MAX (100, 2*lf->u.fam.nalloc);
+ H5F_low_t **x = H5MM_realloc (lf->u.fam.memb,
+ na*sizeof(H5F_low_t*));
+ if (NULL==x) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
+ lf->u.fam.nalloc = na;
+ lf->u.fam.memb = x;
}
lf->u.fam.memb[lf->u.fam.nmemb++] = member;
member = NULL;
@@ -409,10 +418,15 @@ H5F_fam_write(H5F_low_t *lf, const H5F_access_t *access_parms,
* new family member(s)
*/
if (membno >= lf->u.fam.nalloc) {
- lf->u.fam.nalloc = (membno+1)*2;
- lf->u.fam.memb = H5MM_xrealloc(lf->u.fam.memb,
- (lf->u.fam.nalloc *
- sizeof(H5F_low_t *)));
+ size_t na = (membno+1)*2;
+ H5F_low_t **x = H5MM_realloc (lf->u.fam.memb,
+ na*sizeof(H5F_low_t*));
+ if (NULL==x) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
+ lf->u.fam.nalloc = na;
+ lf->u.fam.memb = x;
}
for (i = lf->u.fam.nmemb; i <= membno; i++) {
sprintf(member_name, lf->u.fam.name, i);
diff --git a/src/H5Fistore.c b/src/H5Fistore.c
index de6a1cb..2f23715 100644
--- a/src/H5Fistore.c
+++ b/src/H5Fistore.c
@@ -645,7 +645,11 @@ H5F_istore_init (H5F_t *f)
HDmemset (rdcc, 0, sizeof(H5F_rdcc_t));
if (f->shared->access_parms->rdcc_nbytes>0) {
rdcc->nslots = 25; /*some initial number of slots*/
- rdcc->slot = H5MM_xcalloc (rdcc->nslots, sizeof(H5F_rdcc_ent_t));
+ rdcc->slot = H5MM_calloc (rdcc->nslots*sizeof(H5F_rdcc_ent_t));
+ if (NULL==rdcc->slot) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
}
FUNC_LEAVE (SUCCEED);
@@ -685,7 +689,10 @@ H5F_istore_flush_entry (H5F_t *f, H5F_rdcc_ent_t *ent)
/* Should the chunk be compressed before writing it to disk? */
if (ent->comp && H5Z_NONE!=ent->comp->method) {
- c_buf = H5MM_xmalloc (ent->chunk_size);
+ if (NULL==(c_buf = H5MM_malloc (ent->chunk_size))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed for data compression");
+ }
nbytes = H5Z_compress (ent->comp, ent->chunk_size, ent->chunk, c_buf);
if (nbytes && nbytes<ent->chunk_size) {
out_ptr = c_buf;
@@ -1004,7 +1011,10 @@ H5F_istore_lock (H5F_t *f, const H5O_layout_t *layout,
for (i=0, chunk_size=1; i<layout->ndims; i++) {
chunk_size *= layout->dim[i];
}
- chunk = H5MM_xmalloc (chunk_size);
+ if (NULL==(chunk=H5MM_malloc (chunk_size))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed for raw data chunk");
+ }
} else {
/*
@@ -1018,7 +1028,11 @@ H5F_istore_lock (H5F_t *f, const H5O_layout_t *layout,
udata.mesg = *layout;
H5F_addr_undef (&(udata.addr));
status = H5B_find (f, H5B_ISTORE, &(layout->addr), &udata);
- chunk = H5MM_xmalloc (chunk_size);
+ H5E_clear ();
+ if (NULL==(chunk = H5MM_malloc (chunk_size))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed for raw data chunk");
+ }
if (status>=0 && H5F_addr_defined (&(udata.addr))) {
/*
* The chunk exists on disk but might be compressed. Instead of
@@ -1032,7 +1046,10 @@ H5F_istore_lock (H5F_t *f, const H5O_layout_t *layout,
"unable to read raw data chunk");
}
if (udata.key.nbytes<chunk_size) {
- temp = H5MM_xmalloc (chunk_size);
+ if (NULL==(temp = H5MM_malloc (chunk_size))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed for uncompress");
+ }
if (chunk_size!=H5Z_uncompress (comp, udata.key.nbytes,
chunk, chunk_size, temp)) {
HGOTO_ERROR (H5E_IO, H5E_READERROR, NULL,
@@ -1062,10 +1079,15 @@ H5F_istore_lock (H5F_t *f, const H5O_layout_t *layout,
H5E_clear ();
}
if (rdcc->nused>=rdcc->nslots) {
- rdcc->nslots = MAX (25, 2*rdcc->nslots);
- rdcc->slot = H5MM_xrealloc (rdcc->slot,
- (rdcc->nslots*
- sizeof(H5F_rdcc_ent_t)));
+ size_t na = MAX (25, 2*rdcc->nslots);
+ H5F_rdcc_ent_t *x = H5MM_realloc (rdcc->slot,
+ na*sizeof(H5F_rdcc_ent_t));
+ if (NULL==x) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
+ rdcc->nslots = na;
+ rdcc->slot = x;
}
HDmemmove (rdcc->slot+1, rdcc->slot,
rdcc->nused*sizeof(H5F_rdcc_ent_t));
@@ -1182,8 +1204,9 @@ H5F_istore_unlock (H5F_t *f, const H5O_layout_t *layout,
x.dirty = TRUE;
x.layout = H5O_copy (H5O_LAYOUT, layout);
x.comp = H5O_copy (H5O_COMPRESS, comp);
- for (i=0; i<layout->ndims; i++) {
+ for (i=0, x.chunk_size=1; i<layout->ndims; i++) {
x.offset[i] = offset[i];
+ x.chunk_size *= layout->dim[i];
}
x.chunk = chunk;
H5F_istore_flush_entry (f, &x);
diff --git a/src/H5Fmpio.c b/src/H5Fmpio.c
index d568d26..f71b653 100644
--- a/src/H5Fmpio.c
+++ b/src/H5Fmpio.c
@@ -333,7 +333,10 @@ H5F_mpio_open(const char *name, const H5F_access_t *access_parms, uintn flags,
}
/* Build the return value */
- lf = H5MM_xcalloc(1, sizeof(H5F_low_t));
+ if (NULL==(lf = H5MM_calloc(sizeof(H5F_low_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
lf->u.mpio.f = fh;
H5F_addr_reset(&(lf->eof));
mpierr = MPI_File_get_size( fh, &size );
diff --git a/src/H5Fsec2.c b/src/H5Fsec2.c
index d61d3a0..9b6a0b5 100644
--- a/src/H5Fsec2.c
+++ b/src/H5Fsec2.c
@@ -90,7 +90,10 @@ H5F_sec2_open(const char *name, const H5F_access_t __unused__ *access_parms,
if ((fd = open(name, oflags, 0666)) < 0) {
HRETURN_ERROR(H5E_IO, H5E_CANTOPENFILE, NULL, "open failed");
}
- lf = H5MM_xcalloc(1, sizeof(H5F_low_t));
+ if (NULL==(lf = H5MM_calloc(sizeof(H5F_low_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
lf->u.sec2.fd = fd;
lf->u.sec2.op = H5F_OP_SEEK;
lf->u.sec2.cur = 0;
diff --git a/src/H5Fsplit.c b/src/H5Fsplit.c
index b875023..6e87192 100644
--- a/src/H5Fsplit.c
+++ b/src/H5Fsplit.c
@@ -108,7 +108,10 @@ H5F_split_open(const char *name, const H5F_access_t *access_parms,
raw_type = H5F_low_class (access_parms->u.split.raw_access->driver);
/* Create the file descriptor */
- lf = H5MM_xcalloc(1, sizeof(H5F_low_t));
+ if (NULL==(lf = H5MM_calloc(sizeof(H5F_low_t)))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
lf->u.split.name = H5MM_xstrdup(name);
lf->u.split.mask = H5F_SPLIT_MASK;
diff --git a/src/H5Fstdio.c b/src/H5Fstdio.c
index a472d30..db2b3e2 100644
--- a/src/H5Fstdio.c
+++ b/src/H5Fstdio.c
@@ -107,7 +107,10 @@ H5F_stdio_open(const char *name, const H5F_access_t __unused__ *access_parms,
HRETURN_ERROR(H5E_IO, H5E_CANTOPENFILE, NULL, "fopen failed");
/* Build the return value */
- lf = H5MM_xcalloc(1, sizeof(H5F_low_t));
+ if (NULL==(lf = H5MM_calloc(sizeof(H5F_low_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
lf->u.stdio.f = f;
lf->u.stdio.op = H5F_OP_SEEK;
lf->u.stdio.cur = 0;
diff --git a/src/H5G.c b/src/H5G.c
index e4760a8..c885655 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -1099,7 +1099,10 @@ H5G_mkroot (H5F_t *f, H5G_entry_t *ent)
* don't count the root group as an open object. The root group will
* never be closed.
*/
- f->shared->root_grp = H5MM_xcalloc (1, sizeof(H5G_t));
+ if (NULL==(f->shared->root_grp = H5MM_calloc (sizeof(H5G_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
f->shared->root_grp->ent = *ent;
f->shared->root_grp->nref = 1;
assert (1==f->nopen);
@@ -1171,7 +1174,10 @@ H5G_create(H5G_t *loc, const char *name, size_t size_hint)
}
/* create an open group */
- grp = H5MM_xcalloc(1, sizeof(H5G_t));
+ if (NULL==(grp = H5MM_calloc(sizeof(H5G_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
if (H5G_stab_create(grp_ent.file, size_hint, &(grp->ent)/*out*/) < 0) {
grp = H5MM_xfree(grp);
HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "can't create grp");
@@ -1218,7 +1224,10 @@ H5G_open(H5G_t *loc, const char *name)
assert(name && *name);
/* Open the object, making sure it's a group */
- grp = H5MM_xcalloc(1, sizeof(H5G_t));
+ if (NULL==(grp = H5MM_calloc(sizeof(H5G_t)))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
if (H5G_find(loc, name, NULL, &(grp->ent)/*out*/) < 0) {
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "group not found");
}
@@ -1354,7 +1363,10 @@ H5G_set (H5G_t *grp)
* working group.
*/
if (!f->cwg_stack) {
- f->cwg_stack = H5MM_xcalloc(1, sizeof(H5G_cwgstk_t));
+ if (NULL==(f->cwg_stack = H5MM_calloc(sizeof(H5G_cwgstk_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
} else if (H5G_close(f->cwg_stack->grp) < 0) {
HRETURN_ERROR(H5E_SYM, H5E_CWG, FAIL,
"couldn't close previous current working group");
@@ -1435,7 +1447,10 @@ H5G_push (H5G_t *grp)
/*
* Push a new entry onto the stack.
*/
- stack = H5MM_xcalloc(1, sizeof(H5G_cwgstk_t));
+ if (NULL==(stack = H5MM_calloc(sizeof(H5G_cwgstk_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
stack->grp = H5G_reopen(grp);
stack->next = H5G_fileof(grp)->cwg_stack;
H5G_fileof(grp)->cwg_stack = stack;
diff --git a/src/H5Gent.c b/src/H5Gent.c
index b2120c0..93fb1d7 100644
--- a/src/H5Gent.c
+++ b/src/H5Gent.c
@@ -16,35 +16,7 @@
#define PABLO_MASK H5G_ent_mask
static hbool_t interface_initialize_g = FALSE;
#define INTERFACE_INIT NULL
-
-/*-------------------------------------------------------------------------
- * Function: H5G_ent_calloc
- *
- * Purpose: Returns a pointer to a malloc'd, zeroed symbol table entry.
- *
- * Return: Success: Ptr to entry
- *
- * Failure: never fails
- *
- * Programmer: Robb Matzke
- * Friday, September 19, 1997
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-H5G_entry_t *
-H5G_ent_calloc(H5G_entry_t *init)
-{
- H5G_entry_t *ent;
-
- ent = H5MM_xcalloc(1, sizeof(H5G_entry_t));
- if (init)
- *ent = *init;
- else
- H5F_addr_undef(&(ent->header));
- return ent;
-}
+
/*-------------------------------------------------------------------------
* Function: H5G_ent_cache
diff --git a/src/H5Gnode.c b/src/H5Gnode.c
index 6603799..842e6a0 100644
--- a/src/H5Gnode.c
+++ b/src/H5Gnode.c
@@ -246,7 +246,10 @@ H5G_node_create(H5F_t *f, H5B_ins_t __unused__ op, void *_lt_key,
assert(f);
assert(H5B_INS_FIRST == op);
- sym = H5MM_xcalloc(1, sizeof(H5G_node_t));
+ if (NULL==(sym = H5MM_calloc(sizeof(H5G_node_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
size = H5G_node_size(f);
if (H5MF_alloc(f, H5MF_META, size, addr/*out*/) < 0) {
H5MM_xfree(sym);
@@ -254,7 +257,12 @@ H5G_node_create(H5F_t *f, H5B_ins_t __unused__ op, void *_lt_key,
"unable to allocate file space");
}
sym->dirty = TRUE;
- sym->entry = H5MM_xcalloc((intn)(2*H5G_NODE_K(f)), sizeof(H5G_entry_t));
+ sym->entry = H5MM_calloc(2*H5G_NODE_K(f)*sizeof(H5G_entry_t));
+ if (NULL==sym->entry) {
+ H5MM_xfree (sym);
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
if (H5AC_set(f, H5AC_SNODE, addr, sym) < 0) {
H5MM_xfree(sym->entry);
H5MM_xfree(sym);
@@ -321,7 +329,10 @@ H5G_node_flush(H5F_t *f, hbool_t destroy, const haddr_t *addr,
*/
if (sym->dirty) {
size = H5G_node_size(f);
- buf = p = H5MM_xmalloc(size);
+ if (NULL==(buf = p = H5MM_malloc(size))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
/* magic number */
HDmemcpy(p, H5G_NODE_MAGIC, H5G_NODE_SIZEOF_MAGIC);
@@ -400,10 +411,15 @@ H5G_node_load(H5F_t *f, const haddr_t *addr, const void __unused__ *_udata1,
* Initialize variables.
*/
size = H5G_node_size(f);
- p = buf = H5MM_xmalloc(size);
- sym = H5MM_xcalloc(1, sizeof(H5G_node_t));
- sym->entry = H5MM_xcalloc((intn)(2*H5G_NODE_K(f)), sizeof(H5G_entry_t));
-
+ if (NULL==(p = buf = H5MM_malloc(size))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed for symbol table node");
+ }
+ if (NULL==(sym = H5MM_calloc(sizeof(H5G_node_t))) ||
+ NULL==(sym->entry=H5MM_calloc(2*H5G_NODE_K(f)*sizeof(H5G_entry_t)))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
if (H5F_block_read(f, addr, (hsize_t)size, H5D_XFER_DFLT, buf) < 0) {
HGOTO_ERROR(H5E_SYM, H5E_READERROR, NULL,
"unabel to read symbol table node");
@@ -885,7 +901,10 @@ H5G_node_iterate (H5F_t *f, const haddr_t *addr, void *_udata)
"unable to load symbol table node");
}
nsyms = sn->nsyms;
- name_off = H5MM_xmalloc (nsyms*sizeof(name_off[0]));
+ if (NULL==(name_off = H5MM_malloc (nsyms*sizeof(name_off[0])))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
for (i=0; i<nsyms; i++) name_off[i] = sn->entry[i].name_off;
sn = NULL;
@@ -900,7 +919,14 @@ H5G_node_iterate (H5F_t *f, const haddr_t *addr, void *_udata)
name_off[i]);
assert (name);
n = strlen (name);
- s = n+1>sizeof(buf) ? H5MM_xmalloc (n+1) : buf;
+ if (n+1>sizeof(buf)) {
+ if (NULL==(s = H5MM_malloc (n+1))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
+ } else {
+ s = buf;
+ }
strcpy (s, name);
ret_value = (bt_udata->op)(bt_udata->group_id, s,
bt_udata->op_data);
diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h
index f6a641e..7c76f2d 100644
--- a/src/H5Gprivate.h
+++ b/src/H5Gprivate.h
@@ -136,7 +136,6 @@ herr_t H5G_node_debug (H5F_t *f, const haddr_t *addr, FILE * stream,
* in the H5O package where header messages are cached in symbol table
* entries. The subclasses of H5O probably don't need them though.
*/
-H5G_entry_t *H5G_ent_calloc (H5G_entry_t *init);
H5G_cache_t *H5G_ent_cache (H5G_entry_t *ent, H5G_type_t *cache_type);
herr_t H5G_ent_modified (H5G_entry_t *ent, H5G_type_t cache_type);
herr_t H5G_ent_debug (H5F_t *f, const H5G_entry_t *ent, FILE * stream,
diff --git a/src/H5HG.c b/src/H5HG.c
index 355e063..f2fe211 100644
--- a/src/H5HG.c
+++ b/src/H5HG.c
@@ -108,13 +108,22 @@ H5HG_create (H5F_t *f, size_t size)
HGOTO_ERROR (H5E_HEAP, H5E_CANTINIT, NULL,
"unable to allocate file space for global heap");
}
- heap = H5MM_xcalloc (1, sizeof(H5HG_heap_t));
+ if (NULL==(heap = H5MM_calloc (sizeof(H5HG_heap_t)))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
heap->addr = addr;
heap->size = size;
heap->dirty = TRUE;
- heap->chunk = H5MM_xmalloc (size);
+ if (NULL==(heap->chunk = H5MM_malloc (size))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
heap->nalloc = H5HG_NOBJS (f, size);
- heap->obj = H5MM_xcalloc (heap->nalloc, sizeof(H5HG_obj_t));
+ if (NULL==(heap->obj = H5MM_calloc (heap->nalloc*sizeof(H5HG_obj_t)))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
/* Initialize the header */
HDmemcpy (heap->chunk, H5HG_MAGIC, H5HG_SIZEOF_MAGIC);
@@ -141,7 +150,11 @@ H5HG_create (H5F_t *f, size_t size)
/* Add this heap to the beginning of the CWFS list */
if (NULL==f->shared->cwfs) {
- f->shared->cwfs = H5MM_xmalloc (H5HG_NCWFS * sizeof(H5HG_heap_t*));
+ f->shared->cwfs = H5MM_malloc (H5HG_NCWFS * sizeof(H5HG_heap_t*));
+ if (NULL==(f->shared->cwfs)) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
f->shared->cwfs[0] = heap;
f->shared->ncwfs = 1;
} else {
@@ -187,6 +200,7 @@ H5HG_load (H5F_t *f, const haddr_t *addr, const void __unused__ *udata1,
H5HG_heap_t *ret_value = NULL;
uint8 *p = NULL;
intn i;
+ size_t nalloc;
FUNC_ENTER (H5HG_load, NULL);
@@ -197,9 +211,15 @@ H5HG_load (H5F_t *f, const haddr_t *addr, const void __unused__ *udata1,
assert (!udata2);
/* Read the initial 4k page */
- heap = H5MM_xcalloc (1, sizeof(H5HG_heap_t));
+ if (NULL==(heap = H5MM_calloc (sizeof(H5HG_heap_t)))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
heap->addr = *addr;
- heap->chunk = H5MM_xmalloc (H5HG_MINSIZE);
+ if (NULL==(heap->chunk = H5MM_malloc (H5HG_MINSIZE))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
if (H5F_block_read (f, addr, (hsize_t)H5HG_MINSIZE,
H5D_XFER_DFLT, heap->chunk)<0) {
HGOTO_ERROR (H5E_HEAP, H5E_READERROR, NULL,
@@ -233,7 +253,10 @@ H5HG_load (H5F_t *f, const haddr_t *addr, const void __unused__ *udata1,
if (heap->size > H5HG_MINSIZE) {
haddr_t next_addr = *addr;
H5F_addr_inc (&next_addr, (hsize_t)H5HG_MINSIZE);
- heap->chunk = H5MM_xrealloc (heap->chunk, heap->size);
+ if (NULL==(heap->chunk = H5MM_realloc (heap->chunk, heap->size))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
if (H5F_block_read (f, &next_addr, (hsize_t)(heap->size-H5HG_MINSIZE),
H5D_XFER_DFLT, heap->chunk+H5HG_MINSIZE)<0) {
HGOTO_ERROR (H5E_HEAP, H5E_READERROR, NULL,
@@ -243,8 +266,12 @@ H5HG_load (H5F_t *f, const haddr_t *addr, const void __unused__ *udata1,
/* Decode each object */
p = heap->chunk + H5HG_SIZEOF_HDR (f);
- heap->nalloc = H5HG_NOBJS (f, heap->size);
- heap->obj = H5MM_xcalloc (heap->nalloc, sizeof(H5HG_obj_t));
+ nalloc = H5HG_NOBJS (f, heap->size);
+ if (NULL==(heap->obj = H5MM_calloc (nalloc*sizeof(H5HG_obj_t)))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
+ heap->nalloc = nalloc;
while (p<heap->chunk+heap->size) {
if (p+H5HG_SIZEOF_OBJHDR(f)>heap->chunk+heap->size) {
/*
@@ -276,7 +303,11 @@ H5HG_load (H5F_t *f, const haddr_t *addr, const void __unused__ *udata1,
*/
if (heap->obj[0].size>0) {
if (!f->shared->cwfs) {
- f->shared->cwfs = H5MM_xmalloc (H5HG_NCWFS*sizeof(H5HG_heap_t*));
+ f->shared->cwfs = H5MM_malloc (H5HG_NCWFS*sizeof(H5HG_heap_t*));
+ if (NULL==f->shared->cwfs) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
f->shared->ncwfs = 1;
f->shared->cwfs[0] = heap;
} else if (H5HG_NCWFS==f->shared->ncwfs) {
@@ -647,7 +678,10 @@ H5HG_read (H5F_t *f, H5HG_t *hobj, void *object/*out*/)
assert (heap->obj[hobj->idx].begin);
size = heap->obj[hobj->idx].size - H5HG_SIZEOF_OBJHDR (f);
p = heap->obj[hobj->idx].begin + H5HG_SIZEOF_OBJHDR (f);
- if (!object) object = H5MM_xmalloc (size);
+ if (!object && NULL==(object = H5MM_malloc (size))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
HDmemcpy (object, p, size);
/*
@@ -799,7 +833,7 @@ H5HG_remove (H5F_t *f, H5HG_t *hobj)
* to the file free list.
*/
heap->dirty = FALSE;
- H5MF_free (f, &(heap->addr), (hsize_t)(heap->size));
+ H5MF_xfree (f, &(heap->addr), (hsize_t)(heap->size));
H5AC_flush (f, H5AC_GHEAP, &(heap->addr), TRUE);
heap = NULL;
} else {
diff --git a/src/H5HL.c b/src/H5HL.c
index 8e8f553..88ee521 100644
--- a/src/H5HL.c
+++ b/src/H5HL.c
@@ -96,6 +96,7 @@ H5HL_create(H5F_t *f, size_t size_hint, haddr_t *addr/*out*/)
{
H5HL_t *heap = NULL;
size_t total_size; /*total heap size on disk */
+ herr_t ret_value = FAIL;
FUNC_ENTER(H5HL_create, FAIL);
@@ -111,21 +112,31 @@ H5HL_create(H5F_t *f, size_t size_hint, haddr_t *addr/*out*/)
/* allocate file version */
total_size = H5HL_SIZEOF_HDR(f) + size_hint;
if (H5MF_alloc(f, H5MF_META, (hsize_t)total_size, addr/*out*/) < 0) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ H5F_addr_undef (addr);
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
"unable to allocate file memory");
}
/* allocate memory version */
- heap = H5MM_xcalloc(1, sizeof(H5HL_t));
+ if (NULL==(heap = H5MM_calloc(sizeof(H5HL_t)))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
heap->addr = *addr;
H5F_addr_inc(&(heap->addr), (hsize_t)H5HL_SIZEOF_HDR(f));
heap->disk_alloc = size_hint;
heap->mem_alloc = size_hint;
- heap->chunk = H5MM_xcalloc(1, H5HL_SIZEOF_HDR(f) + size_hint);
+ if (NULL==(heap->chunk = H5MM_calloc(H5HL_SIZEOF_HDR(f) + size_hint))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
/* free list */
if (size_hint) {
- heap->freelist = H5MM_xmalloc(sizeof(H5HL_free_t));
+ if (NULL==(heap->freelist = H5MM_malloc(sizeof(H5HL_free_t)))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
heap->freelist->offset = 0;
heap->freelist->size = size_hint;
heap->freelist->prev = heap->freelist->next = NULL;
@@ -136,12 +147,23 @@ H5HL_create(H5F_t *f, size_t size_hint, haddr_t *addr/*out*/)
/* add to cache */
heap->dirty = 1;
if (H5AC_set(f, H5AC_LHEAP, addr, heap) < 0) {
- heap->chunk = H5MM_xfree(heap->chunk);
- heap->freelist = H5MM_xfree(heap->freelist);
- HRETURN_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL,
- "unable to cache heap");
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL,
+ "unable to cache heap");
}
- FUNC_LEAVE(SUCCEED);
+ ret_value = SUCCEED;
+
+ done:
+ if (ret_value<0) {
+ if (H5F_addr_defined (addr)) {
+ H5MF_xfree (f, addr, total_size);
+ }
+ if (heap) {
+ H5MM_xfree (heap->chunk);
+ H5MM_xfree (heap->freelist);
+ H5MM_xfree (heap);
+ }
+ }
+ FUNC_LEAVE(ret_value);
}
/*-------------------------------------------------------------------------
@@ -187,8 +209,11 @@ H5HL_load(H5F_t *f, const haddr_t *addr, const void __unused__ *udata1,
"unable to read heap header");
}
p = hdr;
- heap = H5MM_xcalloc(1, sizeof(H5HL_t));
-
+ if (NULL==(heap = H5MM_calloc(sizeof(H5HL_t)))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
+
/* magic number */
if (HDmemcmp(hdr, H5HL_MAGIC, H5HL_SIZEOF_MAGIC)) {
HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL,
@@ -212,7 +237,11 @@ H5HL_load(H5F_t *f, const haddr_t *addr, const void __unused__ *udata1,
/* data */
H5F_addr_decode(f, &p, &(heap->addr));
- heap->chunk = H5MM_xcalloc(1, H5HL_SIZEOF_HDR(f) + heap->mem_alloc);
+ heap->chunk = H5MM_calloc(H5HL_SIZEOF_HDR(f) + heap->mem_alloc);
+ if (NULL==heap->chunk) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
if (heap->disk_alloc &&
H5F_block_read(f, &(heap->addr), (hsize_t)(heap->disk_alloc),
H5D_XFER_DFLT, heap->chunk + H5HL_SIZEOF_HDR(f)) < 0) {
@@ -226,7 +255,10 @@ H5HL_load(H5F_t *f, const haddr_t *addr, const void __unused__ *udata1,
HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL,
"bad heap free list");
}
- fl = H5MM_xmalloc(sizeof(H5HL_free_t));
+ if (NULL==(fl = H5MM_malloc(sizeof(H5HL_free_t)))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
fl->offset = free_block;
fl->prev = tail;
fl->next = NULL;
@@ -304,7 +336,7 @@ H5HL_flush(H5F_t *f, hbool_t destroy, const haddr_t *addr, H5HL_t *heap)
"unable to allocate file space for heap");
}
heap->addr = new_addr;
- H5MF_free(f, &old_addr, (hsize_t)(heap->disk_alloc));
+ H5MF_xfree(f, &old_addr, (hsize_t)(heap->disk_alloc));
H5E_clear(); /*don't really care if the free failed */
heap->disk_alloc = heap->mem_alloc;
}
@@ -426,7 +458,10 @@ H5HL_read(H5F_t *f, const haddr_t *addr, size_t offset, size_t size, void *buf)
assert(offset < heap->mem_alloc);
assert(offset + size <= heap->mem_alloc);
- if (!buf) buf = H5MM_xmalloc(size);
+ if (!buf && NULL==(buf = H5MM_malloc(size))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
HDmemcpy(buf, heap->chunk + H5HL_SIZEOF_HDR(f) + offset, size);
FUNC_LEAVE(buf);
@@ -622,7 +657,10 @@ H5HL_insert(H5F_t *f, const haddr_t *addr, size_t buf_size, const void *buf)
*/
offset = heap->mem_alloc;
if (need_more - need_size >= H5HL_SIZEOF_FREE(f)) {
- fl = H5MM_xmalloc(sizeof(H5HL_free_t));
+ if (NULL==(fl = H5MM_malloc(sizeof(H5HL_free_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, (size_t)(-1),
+ "memory allocation failed");
+ }
fl->offset = heap->mem_alloc + need_size;
fl->size = need_more - need_size;
assert (fl->offset==H5HL_ALIGN (fl->offset));
@@ -646,9 +684,13 @@ H5HL_insert(H5F_t *f, const haddr_t *addr, size_t buf_size, const void *buf)
#endif
old_size = heap->mem_alloc;
heap->mem_alloc += need_more;
- heap->chunk = H5MM_xrealloc(heap->chunk,
- H5HL_SIZEOF_HDR(f) + heap->mem_alloc);
-
+ heap->chunk = H5MM_realloc(heap->chunk,
+ H5HL_SIZEOF_HDR(f) + heap->mem_alloc);
+ if (NULL==heap->chunk) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, (size_t)(-1),
+ "memory allocation failed");
+ }
+
/* clear new section so junk doesn't appear in the file */
HDmemset(heap->chunk + H5HL_SIZEOF_HDR(f) + old_size, 0, need_more);
}
@@ -824,7 +866,10 @@ H5HL_remove(H5F_t *f, const haddr_t *addr, size_t offset, size_t size)
/*
* Add an entry to the free list.
*/
- fl = H5MM_xmalloc(sizeof(H5HL_free_t));
+ if (NULL==(fl = H5MM_malloc(sizeof(H5HL_free_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
fl->offset = offset;
fl->size = size;
assert (fl->offset==H5HL_ALIGN (fl->offset));
@@ -894,7 +939,10 @@ H5HL_debug(H5F_t *f, const haddr_t *addr, FILE * stream, intn indent,
* the heap and that no two free blocks point to the same region of
* the heap.
*/
- marker = H5MM_xcalloc(1, h->mem_alloc);
+ if (NULL==(marker = H5MM_calloc(h->mem_alloc))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
for (freelist = h->freelist; freelist; freelist = freelist->next) {
fprintf(stream, "%*s%-*s %8lu, %8lu\n", indent, "", fwidth,
"Free Block (offset,size):",
diff --git a/src/H5I.c b/src/H5I.c
index defd00a..50ea7d6 100644
--- a/src/H5I.c
+++ b/src/H5I.c
@@ -167,7 +167,10 @@ H5I_init_group(H5I_group_t grp, /* IN: Group to initialize */
if (id_group_list[grp] == NULL) {
/* Allocate the group information */
- grp_ptr = H5MM_xcalloc(1, sizeof(H5I_id_group_t));
+ if (NULL==(grp_ptr = H5MM_calloc(sizeof(H5I_id_group_t)))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
id_group_list[grp] = grp_ptr;
} else {
/* Get the pointer to the existing group */
@@ -182,8 +185,11 @@ H5I_init_group(H5I_group_t grp, /* IN: Group to initialize */
grp_ptr->ids = 0;
grp_ptr->nextid = reserved;
grp_ptr->free_func = free_func;
- grp_ptr->id_list = H5MM_xcalloc((intn)hash_size,
- sizeof(H5I_id_info_t *));
+ grp_ptr->id_list = H5MM_calloc(hash_size*sizeof(H5I_id_info_t *));
+ if (NULL==grp_ptr->id_list) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
}
/* Increment the count of the times this group has been initialized */
@@ -773,8 +779,9 @@ H5I_get_id_node(void)
if (id_free_list != NULL) {
ret_value = id_free_list;
id_free_list = id_free_list->next;
- } else {
- ret_value = H5MM_xmalloc(sizeof(H5I_id_info_t));
+ } else if (NULL==(ret_value = H5MM_malloc(sizeof(H5I_id_info_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
}
FUNC_LEAVE(ret_value);
diff --git a/src/H5MF.c b/src/H5MF.c
index 6a51ff7..ddd29ec 100644
--- a/src/H5MF.c
+++ b/src/H5MF.c
@@ -122,7 +122,7 @@ H5MF_alloc(H5F_t *f, intn op, hsize_t size, haddr_t *addr/*out*/)
if (H5F_addr_gt (addr, &(blk.addr))) {
/* Free the first part of the free block */
n = addr->offset - blk.addr.offset;
- H5MF_free (f, &(blk.addr), n);
+ H5MF_xfree (f, &(blk.addr), n);
blk.addr = *addr;
blk.size -= n;
}
@@ -131,7 +131,7 @@ H5MF_alloc(H5F_t *f, intn op, hsize_t size, haddr_t *addr/*out*/)
/* Free the second part of the free block */
H5F_addr_inc (&(blk.addr), size);
blk.size -= size;
- H5MF_free (f, &(blk.addr), blk.size);
+ H5MF_xfree (f, &(blk.addr), blk.size);
}
} else {
@@ -168,14 +168,14 @@ H5MF_alloc(H5F_t *f, intn op, hsize_t size, haddr_t *addr/*out*/)
/* Partial match */
if (H5F_addr_gt (addr, &(blk.addr))) {
n = addr->offset - blk.addr.offset;
- H5MF_free (f, &(blk.addr), n);
+ H5MF_xfree (f, &(blk.addr), n);
blk.addr = *addr;
blk.size -= n;
}
if (blk.size > size) {
H5F_addr_inc (&(blk.addr), size);
blk.size -= size;
- H5MF_free (f, &(blk.addr), blk.size);
+ H5MF_xfree (f, &(blk.addr), blk.size);
}
}
}
@@ -184,7 +184,7 @@ H5MF_alloc(H5F_t *f, intn op, hsize_t size, haddr_t *addr/*out*/)
}
/*-------------------------------------------------------------------------
- * Function: H5MF_free
+ * Function: H5MF_xfree
*
* Purpose: Frees part of a file, making that part of the file
* available for reuse.
@@ -204,16 +204,17 @@ H5MF_alloc(H5F_t *f, intn op, hsize_t size, haddr_t *addr/*out*/)
*-------------------------------------------------------------------------
*/
herr_t
-H5MF_free(H5F_t *f, const haddr_t *addr, hsize_t size)
+H5MF_xfree(H5F_t *f, const haddr_t *addr, hsize_t size)
{
int i;
- FUNC_ENTER(H5MF_free, FAIL);
+ FUNC_ENTER(H5MF_xfree, FAIL);
/* check arguments */
assert(f);
- if (!addr || !H5F_addr_defined(addr) || 0 == size)
+ if (!addr || !H5F_addr_defined(addr) || 0 == size) {
HRETURN(SUCCEED);
+ }
assert(!H5F_addr_zerop(addr));
/*
@@ -294,7 +295,7 @@ H5MF_realloc (H5F_t *f, intn op, hsize_t orig_size, const haddr_t *orig_addr,
} else if (0==new_size) {
/* Degenerate to H5MF_free() */
assert (H5F_addr_defined (orig_addr));
- if (H5MF_free (f, orig_addr, orig_size)<0) {
+ if (H5MF_xfree (f, orig_addr, orig_size)<0) {
HRETURN_ERROR (H5E_RESOURCE, H5E_CANTINIT, FAIL,
"unable to free old file memory");
}
@@ -306,7 +307,7 @@ H5MF_realloc (H5F_t *f, intn op, hsize_t orig_size, const haddr_t *orig_addr,
HRETURN_ERROR (H5E_RESOURCE, H5E_CANTINIT, FAIL,
"unable to allocate new file memory");
}
- if (H5MF_free (f, orig_addr, orig_size)<0) {
+ if (H5MF_xfree (f, orig_addr, orig_size)<0) {
HRETURN_ERROR (H5E_RESOURCE, H5E_CANTINIT, FAIL,
"unable to free old file memory");
}
diff --git a/src/H5MFprivate.h b/src/H5MFprivate.h
index 202f36c..f739467 100644
--- a/src/H5MFprivate.h
+++ b/src/H5MFprivate.h
@@ -38,7 +38,7 @@
* Library prototypes...
*/
herr_t H5MF_alloc (H5F_t *f, intn, hsize_t size, haddr_t *addr/*out*/);
-herr_t H5MF_free (H5F_t *f, const haddr_t *addr, hsize_t size);
+herr_t H5MF_xfree (H5F_t *f, const haddr_t *addr, hsize_t size);
herr_t H5MF_realloc (H5F_t *f, intn op, hsize_t orig_size,
const haddr_t *orig_addr, hsize_t new_size,
haddr_t *new_addr/*out*/);
diff --git a/src/H5MM.c b/src/H5MM.c
index 5a02f41..af38125 100644
--- a/src/H5MM.c
+++ b/src/H5MM.c
@@ -15,41 +15,26 @@
*-------------------------------------------------------------------------
*/
#include <H5private.h>
+#include <H5Eprivate.h>
#include <H5MMprivate.h>
-
-/*-------------------------------------------------------------------------
- * Function: H5MM_xmalloc
- *
- * Purpose: Just like malloc(3) except it aborts on an error.
- *
- * Return: Success: Ptr to new memory.
- *
- * Failure: abort()
- *
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 10 1997
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-void *
-H5MM_xmalloc(size_t size)
-{
- void *mem = HDmalloc(size);
- assert(mem);
- return mem;
-}
+/* Interface initialization? */
+static hbool_t interface_initialize_g = FALSE;
+#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------
- * Function: H5MM_xcalloc
+ * Function: H5MM_realloc
*
- * Purpose: Just like calloc(3) except it aborts on an error.
+ * Purpose: Just like the POSIX version of realloc(3). Specifically, the
+ * following calls are equivalent
*
- * Return: Success: Ptr to memory.
+ * H5MM_realloc (NULL, size) <==> H5MM_malloc (size)
+ * H5MM_realloc (ptr, 0) <==> H5MM_xfree (ptr)
+ * H5MM_realloc (NULL, 0) <==> NULL
+ *
+ * Return: Success: Ptr to new memory or NULL if the memory
+ * was freed.
*
* Failure: abort()
*
@@ -62,34 +47,32 @@ H5MM_xmalloc(size_t size)
*-------------------------------------------------------------------------
*/
void *
-H5MM_xcalloc(intn n, size_t size)
+H5MM_realloc(void *mem, size_t size)
{
- void *mem = NULL;
+ if (!mem) {
+ if (0 == size) return NULL;
+ mem = H5MM_malloc(size);
- assert (n>=0);
+ } else if (0 == size) {
+ mem = H5MM_xfree(mem);
- if (n>0) {
- mem = HDcalloc((size_t)n, size);
+ } else {
+ mem = HDrealloc(mem, size);
assert(mem);
}
-
+
return mem;
}
/*-------------------------------------------------------------------------
- * Function: H5MM_xrealloc
- *
- * Purpose: Just like the POSIX version of realloc(3) exept it aborts
- * on an error. Specifically, the following calls are
- * equivalent
+ * Function: H5MM_xstrdup
*
- * H5MM_xrealloc (NULL, size) <==> H5MM_xmalloc (size)
- * H5MM_xrealloc (ptr, 0) <==> H5MM_xfree (ptr)
- * H5MM_xrealloc (NULL, 0) <==> NULL
+ * Purpose: Duplicates a string. If the string to be duplicated is the
+ * null pointer, then return null. If the string to be duplicated
+ * is the empty string then return a new empty string.
*
- * Return: Success: Ptr to new memory or NULL if the memory
- * was freed.
+ * Return: Success: Ptr to a new string (or null if no string).
*
* Failure: abort()
*
@@ -101,21 +84,15 @@ H5MM_xcalloc(intn n, size_t size)
*
*-------------------------------------------------------------------------
*/
-void *
-H5MM_xrealloc(void *mem, size_t size)
+char *
+H5MM_xstrdup(const char *s)
{
- if (!mem) {
- if (0 == size) return NULL;
- mem = H5MM_xmalloc(size);
-
- } else if (0 == size) {
- mem = H5MM_xfree(mem);
-
- } else {
- mem = HDrealloc(mem, size);
- assert(mem);
- }
+ char *mem;
+ if (!s) return NULL;
+ mem = H5MM_malloc(HDstrlen(s) + 1);
+ assert (mem);
+ HDstrcpy(mem, s);
return mem;
}
@@ -140,14 +117,23 @@ H5MM_xrealloc(void *mem, size_t size)
*-------------------------------------------------------------------------
*/
char *
-H5MM_xstrdup(const char *s)
+H5MM_strdup(const char *s)
{
char *mem;
- if (!s) return NULL;
- mem = H5MM_xmalloc(HDstrlen(s) + 1);
+ FUNC_ENTER (H5MM_strdup, NULL);
+
+ if (!s) {
+ HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, NULL,
+ "null string");
+ }
+ if (NULL==(mem = H5MM_malloc(HDstrlen(s) + 1))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
HDstrcpy(mem, s);
- return mem;
+
+ FUNC_LEAVE (mem);
}
diff --git a/src/H5MMprivate.h b/src/H5MMprivate.h
index 2f715e5..d417584 100644
--- a/src/H5MMprivate.h
+++ b/src/H5MMprivate.h
@@ -22,12 +22,15 @@
/* Private headers needed by this file */
#include <H5private.h>
+#define H5MM_malloc(Z) HDmalloc(Z)
+#define H5MM_calloc(Z) HDcalloc(1,Z)
+
/*
* Library prototypes...
*/
-void *H5MM_xmalloc (size_t size);
-void *H5MM_xcalloc (intn n, size_t size);
-void *H5MM_xrealloc (void *mem, size_t size);
+void *H5MM_realloc (void *mem, size_t size);
char *H5MM_xstrdup (const char *s);
+char *H5MM_strdup (const char *s);
void *H5MM_xfree (void *mem);
+
#endif
diff --git a/src/H5O.c b/src/H5O.c
index d4c861e..29eb583 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -151,11 +151,14 @@ H5O_create(H5F_t *f, size_t size_hint, H5G_entry_t *ent/*out*/)
ent->file = f;
if (H5MF_alloc(f, H5MF_META, (hsize_t)size, &(ent->header)/*out*/) < 0) {
HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "unable to allocate file space for object header hdr");
+ "file allocation failed for object header header");
}
/* allocate the object header and fill in header fields */
- oh = H5MM_xcalloc(1, sizeof(H5O_t));
+ if (NULL==(oh = H5MM_calloc(sizeof(H5O_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
oh->dirty = TRUE;
oh->version = H5O_VERSION;
oh->nlink = 0;
@@ -163,20 +166,27 @@ H5O_create(H5F_t *f, size_t size_hint, H5G_entry_t *ent/*out*/)
/* create the chunk list and initialize the first chunk */
oh->nchunks = 1;
oh->alloc_nchunks = H5O_NCHUNKS;
- oh->chunk = H5MM_xmalloc(oh->alloc_nchunks * sizeof(H5O_chunk_t));
-
+ if (NULL==(oh->chunk=H5MM_malloc(oh->alloc_nchunks*sizeof(H5O_chunk_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
tmp_addr = ent->header;
H5F_addr_inc(&tmp_addr, (hsize_t)H5O_SIZEOF_HDR(f));
oh->chunk[0].dirty = TRUE;
oh->chunk[0].addr = tmp_addr;
oh->chunk[0].size = size_hint;
- oh->chunk[0].image = H5MM_xcalloc(1, size_hint);
-
+ if (NULL==(oh->chunk[0].image = H5MM_calloc(size_hint))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
+
/* create the message list and initialize the first message */
oh->nmesgs = 1;
oh->alloc_nmesgs = H5O_NMESGS;
- oh->mesg = H5MM_xcalloc(oh->alloc_nmesgs, sizeof(H5O_mesg_t));
-
+ if (NULL==(oh->mesg=H5MM_calloc(oh->alloc_nmesgs*sizeof(H5O_mesg_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
oh->mesg[0].type = H5O_NULL;
oh->mesg[0].dirty = TRUE;
oh->mesg[0].native = NULL;
@@ -331,7 +341,10 @@ H5O_load(H5F_t *f, const haddr_t *addr, const void __unused__ *_udata1,
assert(!_udata2);
/* allocate ohdr and init chunk list */
- oh = H5MM_xcalloc(1, sizeof(H5O_t));
+ if (NULL==(oh = H5MM_calloc(sizeof(H5O_t)))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
/* read fixed-lenth part of object header */
hdr_size = H5O_SIZEOF_HDR(f);
@@ -364,16 +377,24 @@ H5O_load(H5F_t *f, const haddr_t *addr, const void __unused__ *_udata1,
/* build the message array */
oh->alloc_nmesgs = MAX(H5O_NMESGS, nmesgs);
- oh->mesg = H5MM_xcalloc(oh->alloc_nmesgs, sizeof(H5O_mesg_t));
+ if (NULL==(oh->mesg=H5MM_calloc(oh->alloc_nmesgs*sizeof(H5O_mesg_t)))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
/* read each chunk from disk */
while (H5F_addr_defined(&chunk_addr)) {
/* increase chunk array size */
if (oh->nchunks >= oh->alloc_nchunks) {
- oh->alloc_nchunks += H5O_NCHUNKS;
- oh->chunk = H5MM_xrealloc(oh->chunk,
- oh->alloc_nchunks * sizeof(H5O_chunk_t));
+ size_t na = oh->alloc_nchunks + H5O_NCHUNKS;
+ H5O_chunk_t *x = H5MM_realloc (oh->chunk, na*sizeof(H5O_chunk_t));
+ if (!x) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
+ oh->alloc_nchunks = na;
+ oh->chunk = x;
}
/* read the chunk raw data */
@@ -381,7 +402,10 @@ H5O_load(H5F_t *f, const haddr_t *addr, const void __unused__ *_udata1,
oh->chunk[chunkno].dirty = FALSE;
oh->chunk[chunkno].addr = chunk_addr;
oh->chunk[chunkno].size = chunk_size;
- oh->chunk[chunkno].image = H5MM_xmalloc(chunk_size);
+ if (NULL==(oh->chunk[chunkno].image = H5MM_malloc(chunk_size))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
if (H5F_block_read(f, &chunk_addr, (hsize_t)chunk_size, H5D_XFER_DFLT,
oh->chunk[chunkno].image) < 0) {
HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL,
@@ -1140,7 +1164,10 @@ H5O_modify(H5G_entry_t *ent, const H5O_class_t *type, intn overwrite,
HGOTO_ERROR (H5E_OHDR, H5E_UNSUPPORTED, FAIL,
"message class is not sharable");
}
- sh_mesg = H5MM_xcalloc (1, sizeof *sh_mesg);
+ if (NULL==(sh_mesg = H5MM_calloc (sizeof *sh_mesg))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
if ((type->get_share)(ent->file, mesg, sh_mesg/*out*/)<0) {
/*
* If the message isn't shared then turn off the shared bit
@@ -1396,9 +1423,13 @@ H5O_alloc_extend_chunk(H5O_t *oh, intn chunkno, size_t size)
old_addr = oh->chunk[chunkno].image;
/* Be careful not to indroduce garbage */
- oh->chunk[chunkno].image = H5MM_xrealloc(old_addr,
- (oh->chunk[chunkno].size +
- delta));
+ oh->chunk[chunkno].image = H5MM_realloc(old_addr,
+ (oh->chunk[chunkno].size +
+ delta));
+ if (NULL==oh->chunk[chunkno].image) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
HDmemset(oh->chunk[chunkno].image + oh->chunk[chunkno].size,
0, delta);
oh->chunk[chunkno].size += delta;
@@ -1418,9 +1449,14 @@ H5O_alloc_extend_chunk(H5O_t *oh, intn chunkno, size_t size)
/* create a new null message */
if (oh->nmesgs >= oh->alloc_nmesgs) {
- oh->alloc_nmesgs += H5O_NMESGS;
- oh->mesg = H5MM_xrealloc(oh->mesg,
- oh->alloc_nmesgs * sizeof(H5O_mesg_t));
+ size_t na = oh->alloc_nmesgs + H5O_NMESGS;
+ H5O_mesg_t *x = H5MM_realloc (oh->mesg, na*sizeof(H5O_mesg_t));
+ if (NULL==x) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
+ oh->alloc_nmesgs = na;
+ oh->mesg = x;
}
delta = MAX(H5O_MIN_SIZE, size+H5O_SIZEOF_MSGHDR(f));
delta = H5O_ALIGN(delta);
@@ -1436,9 +1472,13 @@ H5O_alloc_extend_chunk(H5O_t *oh, intn chunkno, size_t size)
old_addr = oh->chunk[chunkno].image;
oh->chunk[chunkno].size += delta;
- oh->chunk[chunkno].image = H5MM_xrealloc(old_addr,
- oh->chunk[chunkno].size);
-
+ oh->chunk[chunkno].image = H5MM_realloc(old_addr,
+ oh->chunk[chunkno].size);
+ if (NULL==oh->chunk[chunkno].image) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
+
/* adjust raw addresses for messages of this chunk */
if (old_addr != oh->chunk[chunkno].image) {
for (i = 0; i < oh->nmesgs; i++) {
@@ -1543,26 +1583,39 @@ H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size)
* Create the new chunk without giving it a file address.
*/
if (oh->nchunks >= oh->alloc_nchunks) {
- oh->alloc_nchunks += H5O_NCHUNKS;
- oh->chunk = H5MM_xrealloc(oh->chunk,
- oh->alloc_nchunks * sizeof(H5O_chunk_t));
+ size_t na = oh->alloc_nchunks + H5O_NCHUNKS;
+ H5O_chunk_t *x = H5MM_realloc (oh->chunk, na*sizeof(H5O_chunk_t));
+ if (!x) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
+ oh->alloc_nchunks = na;
+ oh->chunk = x;
}
chunkno = oh->nchunks++;
oh->chunk[chunkno].dirty = TRUE;
H5F_addr_undef(&(oh->chunk[chunkno].addr));
oh->chunk[chunkno].size = size;
- oh->chunk[chunkno].image = p = H5MM_xcalloc(1, size);
-
+ if (NULL==(oh->chunk[chunkno].image = p = H5MM_calloc(size))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
+
/*
* Make sure we have enough space for all possible new messages
* that could be generated below.
*/
if (oh->nmesgs + 3 > oh->alloc_nmesgs) {
int old_alloc=oh->alloc_nmesgs;
+ size_t na = oh->alloc_nmesgs + MAX (H5O_NMESGS, 3);
+ H5O_mesg_t *x = H5MM_realloc (oh->mesg, na*sizeof(H5O_mesg_t));
+ if (!x) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
+ oh->alloc_nmesgs = na;
+ oh->mesg = x;
- oh->alloc_nmesgs += MAX(H5O_NMESGS, 3);
- oh->mesg = H5MM_xrealloc(oh->mesg,
- oh->alloc_nmesgs * sizeof(H5O_mesg_t));
/* Set new object header info to zeros */
HDmemset(&oh->mesg[old_alloc], 0,
(oh->alloc_nmesgs-old_alloc)*sizeof(H5O_mesg_t));
@@ -1620,7 +1673,10 @@ H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size)
*/
oh->mesg[found_null].type = H5O_CONT;
oh->mesg[found_null].dirty = TRUE;
- cont = H5MM_xcalloc(1, sizeof(H5O_cont_t));
+ if (NULL==(cont = H5MM_calloc(sizeof(H5O_cont_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
H5F_addr_undef(&(cont->addr));
cont->size = 0;
cont->chunkno = chunkno;
@@ -1707,11 +1763,16 @@ H5O_alloc(H5F_t *f, H5O_t *oh, const H5O_class_t *type, size_t size)
assert(oh->mesg[idx].raw_size - size >= H5O_SIZEOF_MSGHDR(f));
if (oh->nmesgs >= oh->alloc_nmesgs) {
- int old_alloc=oh->alloc_nmesgs;
+ int old_alloc=oh->alloc_nmesgs;
+ size_t na = oh->alloc_nmesgs + H5O_NMESGS;
+ H5O_mesg_t *x = H5MM_realloc (oh->mesg, na*sizeof(H5O_mesg_t));
+ if (!x) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
+ oh->alloc_nmesgs = na;
+ oh->mesg = x;
- oh->alloc_nmesgs += H5O_NMESGS;
- oh->mesg = H5MM_xrealloc(oh->mesg,
- oh->alloc_nmesgs * sizeof(H5O_mesg_t));
/* Set new object header info to zeros */
HDmemset(&oh->mesg[old_alloc],0,
(oh->alloc_nmesgs-old_alloc)*sizeof(H5O_mesg_t));
@@ -1773,7 +1834,10 @@ H5O_share (H5F_t *f, const H5O_class_t *type, const void *mesg,
/* Encode the message put it in the global heap */
if ((size = (type->raw_size)(f, mesg))>0) {
- buf = H5MM_xmalloc (size);
+ if (NULL==(buf = H5MM_malloc (size))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
if ((type->encode)(f, buf, mesg)<0) {
HGOTO_ERROR (H5E_OHDR, H5E_CANTENCODE, FAIL,
"unable to encode message");
@@ -1879,7 +1943,10 @@ H5O_debug(H5F_t *f, const haddr_t *addr, FILE * stream, intn indent,
}
/* debug each message */
- sequence = H5MM_xcalloc(NELMTS(message_type_g), sizeof(int));
+ if (NULL==(sequence = H5MM_calloc(NELMTS(message_type_g)*sizeof(int)))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
for (i=0, mesg_total=0; i<oh->nmesgs; i++) {
mesg_total += H5O_SIZEOF_MSGHDR(f) + oh->mesg[i].raw_size;
fprintf(stream, "%*sMessage %d...\n", indent, "", i);
diff --git a/src/H5Oattr.c b/src/H5Oattr.c
index e252ff0..6a13a91 100644
--- a/src/H5Oattr.c
+++ b/src/H5Oattr.c
@@ -86,11 +86,17 @@ H5O_attr_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
assert(f);
assert(p);
- attr = H5MM_xcalloc(1, sizeof(H5A_t));
-
+ if (NULL==(attr = H5MM_calloc(sizeof(H5A_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
+
/* Decode and store the name */
UINT16DECODE(p, name_len);
- attr->name=H5MM_xmalloc(name_len+1);
+ if (NULL==(attr->name=H5MM_malloc(name_len+1))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
HDmemcpy(attr->name,p,name_len);
attr->name[name_len]='\0';
p+=name_len; /* advance the memory pointer */
@@ -104,7 +110,10 @@ H5O_attr_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
p+=attr->dt_size;
/* decode the attribute dataspace */
- attr->ds = H5MM_xcalloc(1, sizeof(H5S_t));
+ if (NULL==(attr->ds = H5MM_calloc(sizeof(H5S_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
if((simple=(H5O_SDSPACE->decode)(f,p,NULL))!=NULL) {
attr->ds->type = H5S_SIMPLE;
HDmemcpy(&(attr->ds->u.simple),simple, sizeof(H5S_simple_t));
@@ -119,7 +128,10 @@ H5O_attr_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
attr->data_size=H5S_get_npoints(attr->ds)*H5T_get_size(attr->dt);
/* Go get the data */
- attr->data = H5MM_xmalloc(attr->data_size);
+ if (NULL==(attr->data = H5MM_malloc(attr->data_size))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
HDmemcpy(attr->data,p,attr->data_size);
/* Indicate that the fill values aren't to be written out */
@@ -297,7 +309,10 @@ H5O_attr_reset(void *_mesg)
FUNC_ENTER(H5O_attr_reset, FAIL);
if (attr) {
- tmp = H5MM_xmalloc(sizeof(H5A_t));
+ if (NULL==(tmp = H5MM_malloc(sizeof(H5A_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
HDmemcpy(tmp,attr,sizeof(H5A_t));
H5A_close(tmp);
HDmemset(attr, 0, sizeof(H5A_t));
diff --git a/src/H5Ocomp.c b/src/H5Ocomp.c
index 7d659ea..3f341ea 100644
--- a/src/H5Ocomp.c
+++ b/src/H5Ocomp.c
@@ -64,6 +64,7 @@ H5O_comp_decode(H5F_t __unused__ *f, const uint8 *p,
H5O_shared_t __unused__ *sh)
{
H5O_compress_t *comp = NULL;
+ void *ret_value = NULL;
FUNC_ENTER(H5O_comp_decode, NULL);
@@ -71,17 +72,29 @@ H5O_comp_decode(H5F_t __unused__ *f, const uint8 *p,
assert(p);
/* Decode */
- comp = H5MM_xcalloc(1, sizeof *comp);
+ if (NULL==(comp = H5MM_calloc(sizeof *comp))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
comp->method = *p++;
comp->flags = *p++;
UINT16DECODE (p, comp->cd_size);
if (comp->cd_size>0) {
- comp->client_data = H5MM_xmalloc (comp->cd_size);
+ if (NULL==(comp->client_data = H5MM_malloc (comp->cd_size))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
HDmemcpy (comp->client_data, p, comp->cd_size);
}
-
- FUNC_LEAVE(comp);
+ ret_value = comp;
+
+ done:
+ if (NULL==ret_value && comp) {
+ H5MM_xfree (comp->client_data);
+ H5MM_xfree (comp);
+ }
+ FUNC_LEAVE(ret_value);
}
@@ -149,10 +162,16 @@ H5O_comp_copy (const void *_src, void *_dst/*out*/)
FUNC_ENTER (H5O_comp_copy, NULL);
- if (!dst) dst = H5MM_xmalloc (sizeof *dst);
+ if (!dst && NULL==(dst = H5MM_malloc (sizeof *dst))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
*dst = *src;
if (src->cd_size>0) {
- dst->client_data = H5MM_xmalloc (src->cd_size);
+ if (NULL==(dst->client_data = H5MM_malloc (src->cd_size))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
HDmemcpy (dst->client_data, src->client_data, src->cd_size);
}
diff --git a/src/H5Ocont.c b/src/H5Ocont.c
index ff81be9..ab913e2 100644
--- a/src/H5Ocont.c
+++ b/src/H5Ocont.c
@@ -79,7 +79,10 @@ H5O_cont_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
assert (!sh);
/* decode */
- cont = H5MM_xcalloc(1, sizeof(H5O_cont_t));
+ if (NULL==(cont = H5MM_calloc(sizeof(H5O_cont_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
H5F_addr_decode(f, &p, &(cont->addr));
H5F_decode_length(f, p, cont->size);
diff --git a/src/H5Odtype.c b/src/H5Odtype.c
index c53152e..6ff75d9 100644
--- a/src/H5Odtype.c
+++ b/src/H5Odtype.c
@@ -160,8 +160,11 @@ H5O_dtype_decode_helper(const uint8 **pp, H5T_t *dt)
dt->u.compnd.nmembs = flags & 0xffff;
assert(dt->u.compnd.nmembs > 0);
dt->u.compnd.nalloc = dt->u.compnd.nmembs;
- dt->u.compnd.memb = H5MM_xcalloc(dt->u.compnd.nalloc,
- sizeof(H5T_member_t));
+ dt->u.compnd.memb = H5MM_calloc(dt->u.compnd.nalloc*sizeof(H5T_member_t));
+ if (NULL==dt->u.compnd.memb) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
for (i = 0; i < dt->u.compnd.nmembs; i++) {
dt->u.compnd.memb[i].name = H5MM_xstrdup((const char *)*pp);
*pp += ((HDstrlen((const char *)*pp) + 8) / 8) * 8; /*multiple of 8 w/ null terminator */
@@ -177,7 +180,11 @@ H5O_dtype_decode_helper(const uint8 **pp, H5T_t *dt)
dt->u.compnd.memb[i].perm[1] = (perm_word >> 8) & 0xff;
dt->u.compnd.memb[i].perm[2] = (perm_word >> 16) & 0xff;
dt->u.compnd.memb[i].perm[3] = (perm_word >> 24) & 0xff;
- dt->u.compnd.memb[i].type = H5MM_xcalloc (1, sizeof(H5T_t));
+ dt->u.compnd.memb[i].type = H5MM_calloc (sizeof(H5T_t));
+ if (NULL==dt->u.compnd.memb[i].type) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
H5F_addr_undef (&(dt->u.compnd.memb[i].type->ent.header));
if (H5O_dtype_decode_helper(pp, dt->u.compnd.memb[i].type) < 0 ||
H5T_COMPOUND == dt->u.compnd.memb[i].type->type) {
@@ -451,7 +458,10 @@ H5O_dtype_decode(H5F_t __unused__ *f, const uint8 *p,
/* check args */
assert(p);
- dt = H5MM_xcalloc(1, sizeof(H5T_t));
+ if (NULL==(dt = H5MM_calloc(sizeof(H5T_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
H5F_addr_undef (&(dt->ent.header));
if (H5O_dtype_decode_helper(&p, dt) < 0) {
@@ -618,7 +628,10 @@ H5O_dtype_reset(void *_mesg)
FUNC_ENTER(H5O_dtype_reset, FAIL);
if (dt) {
- tmp = H5MM_xmalloc(sizeof(H5T_t));
+ if (NULL==(tmp = H5MM_malloc(sizeof(H5T_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
*tmp = *dt;
H5T_close(tmp);
HDmemset(dt, 0, sizeof(H5T_t));
diff --git a/src/H5Oefl.c b/src/H5Oefl.c
index 246aa79..94e2650 100644
--- a/src/H5Oefl.c
+++ b/src/H5Oefl.c
@@ -74,7 +74,10 @@ H5O_efl_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
assert (!sh);
/* Decode the header */
- mesg = H5MM_xcalloc(1, sizeof(H5O_efl_t));
+ if (NULL==(mesg = H5MM_calloc(sizeof(H5O_efl_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
H5F_addr_decode(f, &p, &(mesg->heap_addr));
#ifndef NDEBUG
assert (H5F_addr_defined (&(mesg->heap_addr)));
@@ -88,7 +91,12 @@ H5O_efl_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
p += 4; /*reserved*/
/* Decode the file list */
- mesg->slot = H5MM_xcalloc(mesg->nalloc, sizeof(H5O_efl_entry_t));
+ mesg->slot = H5MM_calloc(mesg->nalloc*sizeof(H5O_efl_entry_t));
+ if (NULL==mesg->slot) {
+ H5MM_xfree (mesg);
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
for (i=0; i<mesg->nused; i++) {
/* Name */
H5F_decode_length (f, p, mesg->slot[i].name_offset);
@@ -205,11 +213,20 @@ H5O_efl_copy(const void *_mesg, void *_dest)
/* check args */
assert(mesg);
if (!dest) {
- dest = H5MM_xcalloc(1, sizeof(H5O_efl_t));
- dest->slot = H5MM_xmalloc(mesg->nalloc * sizeof(H5O_efl_entry_t));
+ if (NULL==(dest = H5MM_calloc(sizeof(H5O_efl_t))) ||
+ NULL==(dest->slot=H5MM_malloc(mesg->nalloc*
+ sizeof(H5O_efl_entry_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
+
} else if (NULL==dest->slot || dest->nalloc<mesg->nalloc) {
H5MM_xfree(dest->slot);
- dest->slot = H5MM_xmalloc(mesg->nalloc * sizeof(H5O_efl_entry_t));
+ if (NULL==(dest->slot = H5MM_malloc(mesg->nalloc*
+ sizeof(H5O_efl_entry_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
}
dest->heap_addr = mesg->heap_addr;
dest->nalloc = mesg->nalloc;
diff --git a/src/H5Olayout.c b/src/H5Olayout.c
index 510c0dd..3c534fa 100644
--- a/src/H5Olayout.c
+++ b/src/H5Olayout.c
@@ -73,7 +73,10 @@ H5O_layout_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
assert (!sh);
/* decode */
- mesg = H5MM_xcalloc(1, sizeof(H5O_layout_t));
+ if (NULL==(mesg = H5MM_calloc(sizeof(H5O_layout_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
H5F_addr_decode(f, &p, &(mesg->addr));
mesg->ndims = *p++;
@@ -170,8 +173,11 @@ H5O_layout_copy(const void *_mesg, void *_dest)
/* check args */
assert(mesg);
- if (!dest) dest = H5MM_xcalloc(1, sizeof(H5O_layout_t));
-
+ if (!dest && NULL==(dest=H5MM_calloc(sizeof(H5O_layout_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
+
/* copy */
*dest = *mesg;
diff --git a/src/H5Oname.c b/src/H5Oname.c
index acf6764..97a7e10 100644
--- a/src/H5Oname.c
+++ b/src/H5Oname.c
@@ -82,8 +82,12 @@ H5O_name_decode(H5F_t __unused__ *f, const uint8 *p,
assert (!sh);
/* decode */
- mesg = H5MM_xcalloc(1, sizeof(H5O_name_t));
- mesg->s = H5MM_xmalloc (strlen ((const char*)p)+1);
+ if (NULL==(mesg = H5MM_calloc(sizeof(H5O_name_t))) ||
+ NULL==(mesg->s = H5MM_malloc (strlen ((const char*)p)+1))) {
+ H5MM_xfree (mesg);
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
strcpy (mesg->s, (const char*)p);
FUNC_LEAVE(mesg);
@@ -141,7 +145,7 @@ H5O_name_encode(H5F_t __unused__ *f, uint8 *p, const void *_mesg)
*
*-------------------------------------------------------------------------
*/
-static void *
+static void *
H5O_name_copy(const void *_mesg, void *_dest)
{
const H5O_name_t *mesg = (const H5O_name_t *) _mesg;
@@ -151,9 +155,11 @@ H5O_name_copy(const void *_mesg, void *_dest)
/* check args */
assert(mesg);
- if (!dest)
- dest = H5MM_xcalloc(1, sizeof(H5O_name_t));
-
+ if (!dest && NULL==(dest = H5MM_calloc(sizeof(H5O_name_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
+
/* copy */
*dest = *mesg;
dest->s = H5MM_xstrdup(mesg->s);
diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c
index 66361e4..a780af3 100644
--- a/src/H5Osdspace.c
+++ b/src/H5Osdspace.c
@@ -90,22 +90,34 @@ H5O_sdspace_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
assert (!sh);
/* decode */
- if ((sdim = H5MM_xcalloc(1, sizeof(H5S_simple_t))) != NULL) {
+ if ((sdim = H5MM_calloc(sizeof(H5S_simple_t))) != NULL) {
UINT32DECODE(p, sdim->rank);
UINT32DECODE(p, flags);
if (sdim->rank > 0) {
- sdim->size = H5MM_xmalloc(sizeof(sdim->size[0]) * sdim->rank);
+ if (NULL==(sdim->size=H5MM_malloc(sizeof(sdim->size[0])*
+ sdim->rank))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
for (u = 0; u < sdim->rank; u++) {
H5F_decode_length (f, p, sdim->size[u]);
}
if (flags & 0x01) {
- sdim->max = H5MM_xmalloc(sizeof(sdim->max[0]) * sdim->rank);
+ if (NULL==(sdim->max=H5MM_malloc(sizeof(sdim->max[0])*
+ sdim->rank))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
for (u = 0; u < sdim->rank; u++) {
H5F_decode_length (f, p, sdim->max[u]);
}
}
if (flags & 0x02) {
- sdim->perm = H5MM_xmalloc(sizeof(sdim->perm[0]) * sdim->rank);
+ if (NULL==(sdim->perm=H5MM_malloc(sizeof(sdim->perm[0])*
+ sdim->rank))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
for (u = 0; u < sdim->rank; u++)
UINT32DECODE(p, sdim->perm[u]);
}
@@ -207,22 +219,33 @@ H5O_sdspace_copy(const void *mesg, void *dest)
/* check args */
assert(src);
- if (!dst)
- dst = H5MM_xcalloc(1, sizeof(H5S_simple_t));
+ if (!dst && NULL==(dst = H5MM_calloc(sizeof(H5S_simple_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
/* deep copy -- pointed-to values are copied also */
HDmemcpy(dst, src, sizeof(H5S_simple_t));
if (src->size) {
- dst->size = H5MM_xcalloc(src->rank, sizeof(src->size[0]));
+ if (NULL==(dst->size = H5MM_calloc(src->rank*sizeof(src->size[0])))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
HDmemcpy (dst->size, src->size, src->rank*sizeof(src->size[0]));
}
if (src->max) {
- dst->max = H5MM_xcalloc(src->rank, sizeof(src->max[0]));
+ if (NULL==(dst->max=H5MM_calloc(src->rank*sizeof(src->max[0])))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
HDmemcpy (dst->max, src->max, src->rank*sizeof(src->max[0]));
}
if (src->perm) {
- dst->perm = H5MM_xcalloc(src->rank, sizeof(src->perm[0]));
+ if (NULL==(dst->perm=H5MM_calloc(src->rank*sizeof(src->perm[0])))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
HDmemcpy (dst->perm, src->perm, src->rank*sizeof(src->perm[0]));
}
diff --git a/src/H5Oshared.c b/src/H5Oshared.c
index 2789297..b5c810b 100644
--- a/src/H5Oshared.c
+++ b/src/H5Oshared.c
@@ -73,7 +73,10 @@ H5O_shared_decode (H5F_t *f, const uint8 *buf, H5O_shared_t __unused__ *sh)
assert (!sh);
/* Decode */
- mesg = H5MM_xcalloc (1, sizeof *mesg);
+ if (NULL==(mesg = H5MM_calloc (sizeof *mesg))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
UINT32DECODE (buf, mesg->in_gh);
if (mesg->in_gh) {
H5F_addr_decode (f, &buf, &(mesg->u.gh.addr));
diff --git a/src/H5Ostab.c b/src/H5Ostab.c
index 7eb8d6e..447bd58 100644
--- a/src/H5Ostab.c
+++ b/src/H5Ostab.c
@@ -80,7 +80,10 @@ H5O_stab_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
assert (!sh);
/* decode */
- stab = H5MM_xcalloc(1, sizeof(H5O_stab_t));
+ if (NULL==(stab = H5MM_calloc(sizeof(H5O_stab_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
H5F_addr_decode(f, &p, &(stab->btree_addr));
H5F_addr_decode(f, &p, &(stab->heap_addr));
@@ -154,8 +157,12 @@ H5O_stab_fast(const H5G_cache_t *cache, const H5O_class_t *type, void *_mesg)
assert(type);
if (H5O_STAB == type) {
- if (_mesg) stab = (H5O_stab_t *) _mesg;
- else stab = H5MM_xcalloc(1, sizeof(H5O_stab_t));
+ if (_mesg) {
+ stab = (H5O_stab_t *) _mesg;
+ } else if (NULL==(stab = H5MM_calloc(sizeof(H5O_stab_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
stab->btree_addr = cache->stab.btree_addr;
stab->heap_addr = cache->stab.heap_addr;
}
@@ -190,9 +197,11 @@ H5O_stab_copy(const void *_mesg, void *_dest)
/* check args */
assert(stab);
- if (!dest)
- dest = H5MM_xcalloc(1, sizeof(H5O_stab_t));
-
+ if (!dest && NULL==(dest = H5MM_calloc(sizeof(H5O_stab_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
+
/* copy */
*dest = *stab;
diff --git a/src/H5P.c b/src/H5P.c
index 4e74e45..29e22e7 100644
--- a/src/H5P.c
+++ b/src/H5P.c
@@ -157,22 +157,34 @@ H5Pcreate (H5P_class_t type)
/* Allocate a new property list and initialize it with default values */
switch (type) {
case H5P_FILE_CREATE:
- tmpl = H5MM_xmalloc(sizeof(H5F_create_t));
+ if (NULL==(tmpl = H5MM_malloc(sizeof(H5F_create_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
memcpy(tmpl, &H5F_create_dflt, sizeof(H5F_create_t));
break;
case H5P_FILE_ACCESS:
- tmpl = H5MM_xmalloc(sizeof(H5F_access_t));
+ if (NULL==(tmpl = H5MM_malloc(sizeof(H5F_access_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
memcpy(tmpl, &H5F_access_dflt, sizeof(H5F_access_t));
break;
case H5P_DATASET_CREATE:
- tmpl = H5MM_xmalloc(sizeof(H5D_create_t));
+ if (NULL==(tmpl = H5MM_malloc(sizeof(H5D_create_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
memcpy(tmpl, &H5D_create_dflt, sizeof(H5D_create_t));
break;
case H5P_DATASET_XFER:
- tmpl = H5MM_xmalloc(sizeof(H5D_xfer_t));
+ if (NULL==(tmpl = H5MM_malloc(sizeof(H5D_xfer_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
memcpy(tmpl, &H5D_xfer_dflt, sizeof(H5D_xfer_t));
break;
@@ -1147,10 +1159,15 @@ H5Pset_external (hid_t plist_id, const char *name, off_t offset, hsize_t size)
/* Add to the list */
if (plist->efl.nused>=plist->efl.nalloc) {
- plist->efl.nalloc += H5O_EFL_ALLOC;
- plist->efl.slot = H5MM_xrealloc (plist->efl.slot,
- (plist->efl.nalloc *
- sizeof(H5O_efl_entry_t)));
+ size_t na = plist->efl.nalloc + H5O_EFL_ALLOC;
+ H5O_efl_entry_t *x = H5MM_realloc (plist->efl.slot,
+ na*sizeof(H5O_efl_entry_t));
+ if (!x) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
+ plist->efl.nalloc = na;
+ plist->efl.slot = x;
}
idx = plist->efl.nused;
plist->efl.slot[idx].name_offset = 0; /*not entered into heap yet*/
@@ -2139,7 +2156,10 @@ H5Pset_compression (hid_t plist_id, H5Z_method_t method, unsigned int flags,
plist->compress.flags = flags;
plist->compress.cd_size = cd_size;
if (cd_size) {
- plist->compress.client_data = H5MM_xmalloc (cd_size);
+ if (NULL==(plist->compress.client_data = H5MM_malloc (cd_size))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
HDmemcpy (plist->compress.client_data, client_data, cd_size);
}
FUNC_LEAVE (SUCCEED);
@@ -2641,7 +2661,10 @@ H5P_copy (H5P_class_t type, const void *src)
}
/* Create the new property list */
- dst = H5MM_xmalloc(size);
+ if (NULL==(dst = H5MM_malloc(size))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
HDmemcpy(dst, src, size);
/* Deep-copy pointers */
@@ -2680,8 +2703,12 @@ H5P_copy (H5P_class_t type, const void *src)
dc_dst = (H5D_create_t*)dst;
if (dc_src->efl.nalloc>0) {
- dc_dst->efl.slot = H5MM_xmalloc (dc_dst->efl.nalloc *
- sizeof(H5O_efl_entry_t));
+ dc_dst->efl.slot = H5MM_malloc (dc_dst->efl.nalloc *
+ sizeof(H5O_efl_entry_t));
+ if (NULL==dc_dst->efl.slot) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
for (i=0; i<dc_src->efl.nused; i++) {
char *s = H5MM_xstrdup (dc_src->efl.slot[i].name);
dc_dst->efl.slot[i] = dc_src->efl.slot[i];
diff --git a/src/H5S.c b/src/H5S.c
index 092f569..8802a68 100644
--- a/src/H5S.c
+++ b/src/H5S.c
@@ -136,7 +136,10 @@ H5Screate_simple (int rank, const hsize_t *dims, const hsize_t *maxdims)
}
/* Create a new data space */
- ds = H5MM_xcalloc(1, sizeof(H5S_t));
+ if (NULL==(ds = H5MM_calloc(sizeof(H5S_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
if(rank>0) /* for creating simple dataspace */
{
ds->type = H5S_SIMPLE;
@@ -145,11 +148,17 @@ H5Screate_simple (int rank, const hsize_t *dims, const hsize_t *maxdims)
/* Initialize rank and dimensions */
ds->u.simple.rank = rank;
- ds->u.simple.size = H5MM_xcalloc(1, rank*sizeof(hsize_t));
+ if (NULL==(ds->u.simple.size = H5MM_calloc(1*rank*sizeof(hsize_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
HDmemcpy(ds->u.simple.size, dims, rank*sizeof(hsize_t));
if (maxdims) {
- ds->u.simple.max = H5MM_xcalloc(1, rank*sizeof(hsize_t));
+ if (NULL==(ds->u.simple.max=H5MM_calloc(rank*sizeof(hsize_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
HDmemcpy (ds->u.simple.max, maxdims, rank*sizeof(hsize_t));
}
} /* end if */
@@ -361,7 +370,10 @@ H5S_copy(const H5S_t *src)
FUNC_ENTER(H5S_copy, NULL);
- dst = H5MM_xmalloc(sizeof(H5S_t));
+ if (NULL==(dst = H5MM_malloc(sizeof(H5S_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
*dst = *src;
switch (dst->type) {
@@ -371,22 +383,34 @@ H5S_copy(const H5S_t *src)
case H5S_SIMPLE:
if (dst->u.simple.size) {
- dst->u.simple.size = H5MM_xmalloc(dst->u.simple.rank *
- sizeof(dst->u.simple.size[0]));
+ dst->u.simple.size = H5MM_malloc(dst->u.simple.rank *
+ sizeof(dst->u.simple.size[0]));
+ if (NULL==dst->u.simple.size) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
for (i = 0; i < dst->u.simple.rank; i++) {
dst->u.simple.size[i] = src->u.simple.size[i];
}
}
if (dst->u.simple.max) {
- dst->u.simple.max = H5MM_xmalloc(dst->u.simple.rank *
- sizeof(dst->u.simple.max[0]));
+ dst->u.simple.max = H5MM_malloc(dst->u.simple.rank *
+ sizeof(dst->u.simple.max[0]));
+ if (NULL==dst->u.simple.max) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
for (i = 0; i < dst->u.simple.rank; i++) {
dst->u.simple.max[i] = src->u.simple.max[i];
}
}
if (dst->u.simple.perm) {
- dst->u.simple.perm = H5MM_xmalloc(dst->u.simple.rank *
- sizeof(dst->u.simple.perm[0]));
+ dst->u.simple.perm = H5MM_malloc(dst->u.simple.rank *
+ sizeof(dst->u.simple.perm[0]));
+ if (NULL==dst->u.simple.perm) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
for (i = 0; i < dst->u.simple.rank; i++) {
dst->u.simple.perm[i] = src->u.simple.perm[i];
}
@@ -835,8 +859,11 @@ H5S_read(H5G_entry_t *ent)
/* check args */
assert(ent);
- ds = H5MM_xcalloc(1, sizeof(H5S_t));
-
+ if (NULL==(ds = H5MM_calloc(sizeof(H5S_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
+
if (H5O_read(ent, H5O_SDSPACE, 0, &(ds->u.simple))) {
ds->type = H5S_SIMPLE;
@@ -1097,7 +1124,10 @@ H5Sset_space (hid_t sid, int rank, const hsize_t *dims)
} else {
/* Set the rank and copy the dims */
space->u.simple.rank = rank;
- space->u.simple.size = H5MM_xcalloc(rank, sizeof(hsize_t));
+ if (NULL==(space->u.simple.size=H5MM_calloc(rank*sizeof(hsize_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
HDmemcpy(space->u.simple.size, dims, sizeof(hsize_t) * rank);
}
FUNC_LEAVE(ret_value);
@@ -1153,7 +1183,11 @@ H5Sset_hyperslab (hid_t sid, const hssize_t *start, const hsize_t *count,
}
/* Set up stride values for later use */
- tmp_stride= H5MM_xmalloc(space->u.simple.rank*sizeof(tmp_stride[0]));
+ tmp_stride=H5MM_malloc(space->u.simple.rank*sizeof(tmp_stride[0]));
+ if (NULL==tmp_stride) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
for (u=0; u<space->u.simple.rank; u++) {
tmp_stride[u] = stride ? stride[u] : 1;
}
@@ -1173,9 +1207,15 @@ H5Sset_hyperslab (hid_t sid, const hssize_t *start, const hsize_t *count,
/* Allocate space for the hyperslab information */
if (NULL==space->h.start) {
- space->h.start= H5MM_xcalloc(space->u.simple.rank, sizeof(hsize_t));
- space->h.count= H5MM_xcalloc(space->u.simple.rank, sizeof(hsize_t));
- space->h.stride= H5MM_xcalloc(space->u.simple.rank, sizeof(hsize_t));
+ space->h.start=H5MM_calloc(space->u.simple.rank*sizeof(hsize_t));
+ space->h.count=H5MM_calloc(space->u.simple.rank*sizeof(hsize_t));
+ space->h.stride=H5MM_calloc(space->u.simple.rank*sizeof(hsize_t));
+ if (NULL==space->h.start ||
+ NULL==space->h.count ||
+ NULL==space->h.stride) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
}
/* Build hyperslab */
diff --git a/src/H5T.c b/src/H5T.c
index bdeda66..9297634 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -167,7 +167,10 @@ H5T_init_interface(void)
dt->u.atomic.prec = 64;
/* Opaque data */
- dt = H5MM_xcalloc(1, sizeof(H5T_t));
+ if (NULL==(dt = H5MM_calloc(sizeof(H5T_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
dt->state = H5T_STATE_IMMUTABLE;
H5F_addr_undef (&(dt->ent.header));
dt->type = H5T_OPAQUE;
@@ -514,7 +517,10 @@ H5T_init_interface(void)
*/
/* One-byte character string */
- dt = H5MM_xcalloc(1, sizeof(H5T_t));
+ if (NULL==(dt = H5MM_calloc(sizeof(H5T_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
dt->state = H5T_STATE_IMMUTABLE;
H5F_addr_undef (&(dt->ent.header));
dt->type = H5T_STRING;
@@ -537,7 +543,10 @@ H5T_init_interface(void)
*/
/* One-byte character string */
- dt = H5MM_xcalloc(1, sizeof(H5T_t));
+ if (NULL==(dt = H5MM_calloc(sizeof(H5T_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
dt->state = H5T_STATE_IMMUTABLE;
H5F_addr_undef (&(dt->ent.header));
dt->type = H5T_STRING;
@@ -2864,9 +2873,14 @@ H5Tregister_soft (const char *name, H5T_class_t src_cls, H5T_class_t dst_cls,
/* Add function to end of master list */
if (H5T_nsoft_g >= H5T_asoft_g) {
- H5T_asoft_g = MAX(32, 2 * H5T_asoft_g);
- H5T_soft_g = H5MM_xrealloc(H5T_soft_g,
- H5T_asoft_g * sizeof(H5T_soft_t));
+ size_t na = MAX (32, 2*H5T_asoft_g);
+ H5T_soft_t *x = H5MM_realloc (H5T_soft_g, na*sizeof(H5T_soft_t));
+ if (!x) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
+ H5T_asoft_g = na;
+ H5T_soft_g = x;
}
HDstrncpy (H5T_soft_g[H5T_nsoft_g].name, name, H5T_NAMELEN);
H5T_soft_g[H5T_nsoft_g].name[H5T_NAMELEN-1] = '\0';
@@ -2901,7 +2915,10 @@ H5Tregister_soft (const char *name, H5T_class_t src_cls, H5T_class_t dst_cls,
HDmemset (&cdata, 0, sizeof cdata);
cdata.command = H5T_CONV_INIT;
- cdata.stats = H5MM_xcalloc (1, sizeof(H5T_stats_t));
+ if (NULL==(cdata.stats = H5MM_calloc (sizeof(H5T_stats_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
if ((func) (src_id, dst_id, &cdata, 0, NULL, NULL) >= 0) {
/*
* Free resources used by the previous conversion function. We
@@ -3025,7 +3042,11 @@ H5Tunregister (H5T_conv_t func)
}
path->cdata.command = H5T_CONV_INIT;
- path->cdata.stats = H5MM_xcalloc (1, sizeof(H5T_stats_t));
+ path->cdata.stats = H5MM_calloc (sizeof(H5T_stats_t));
+ if (NULL==path->cdata.stats) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
if ((H5T_soft_g[j].func)(src_id, dst_id, &(path->cdata),
0, NULL, NULL) >= 0) {
HDstrcpy (path->name, H5T_soft_g[j].name);
@@ -3202,7 +3223,10 @@ H5T_create(H5T_class_t type, size_t size)
"type class is not appropriate - use H5Tcopy()");
case H5T_COMPOUND:
- dt = H5MM_xcalloc(1, sizeof(H5T_t));
+ if (NULL==(dt = H5MM_calloc(sizeof(H5T_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
dt->type = type;
break;
@@ -3308,7 +3332,10 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
assert(old_dt);
/* copy */
- new_dt = H5MM_xcalloc(1, sizeof(H5T_t));
+ if (NULL==(new_dt = H5MM_calloc(sizeof(H5T_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
*new_dt = *old_dt;
switch (method) {
@@ -3355,8 +3382,12 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
* name and type fields of each new member with copied values.
* That is, H5T_copy() is a deep copy.
*/
- new_dt->u.compnd.memb = H5MM_xmalloc(new_dt->u.compnd.nmembs *
- sizeof(H5T_member_t));
+ new_dt->u.compnd.memb = H5MM_malloc(new_dt->u.compnd.nmembs *
+ sizeof(H5T_member_t));
+ if (NULL==new_dt->u.compnd.memb) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
HDmemcpy(new_dt->u.compnd.memb, old_dt->u.compnd.memb,
new_dt->u.compnd.nmembs * sizeof(H5T_member_t));
@@ -3659,10 +3690,15 @@ H5T_insert(H5T_t *parent, const char *name, size_t offset, const H5T_t *member)
/* Increase member array if necessary */
if (parent->u.compnd.nmembs >= parent->u.compnd.nalloc) {
- parent->u.compnd.nalloc += H5T_COMPND_INC;
- parent->u.compnd.memb = H5MM_xrealloc(parent->u.compnd.memb,
- (parent->u.compnd.nalloc *
- sizeof(H5T_member_t)));
+ size_t na = parent->u.compnd.nalloc + H5T_COMPND_INC;
+ H5T_member_t *x = H5MM_realloc (parent->u.compnd.memb,
+ na * sizeof(H5T_member_t));
+ if (!x) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
+ parent->u.compnd.nalloc = na;
+ parent->u.compnd.memb = x;
}
/* Add member to end of member array */
@@ -3831,8 +3867,11 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2)
if (dt1->u.compnd.nmembs > dt2->u.compnd.nmembs) HGOTO_DONE(1);
/* Build an index for each type so the names are sorted */
- idx1 = H5MM_xmalloc(dt1->u.compnd.nmembs * sizeof(intn));
- idx2 = H5MM_xmalloc(dt1->u.compnd.nmembs * sizeof(intn));
+ if (NULL==(idx1 = H5MM_malloc(dt1->u.compnd.nmembs * sizeof(intn))) ||
+ NULL==(idx2 = H5MM_malloc(dt1->u.compnd.nmembs * sizeof(intn)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, 0,
+ "memory allocation failed");
+ }
for (i=0; i<dt1->u.compnd.nmembs; i++) idx1[i] = idx2[i] = i;
for (i=dt1->u.compnd.nmembs-1, swapped=TRUE; swapped && i>=0; --i) {
for (j=0, swapped=FALSE; j<i; j++) {
@@ -4063,8 +4102,10 @@ H5T_find(const H5T_t *src, const H5T_t *dst, H5T_bkg_t need_bkg,
FUNC_ENTER(H5T_find, NULL);
- if (!noop_cdata.stats) {
- noop_cdata.stats = H5MM_xcalloc (1, sizeof(H5T_stats_t));
+ if (!noop_cdata.stats &&
+ NULL==(noop_cdata.stats = H5MM_calloc (sizeof(H5T_stats_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
}
/* No-op case */
@@ -4149,9 +4190,15 @@ H5T_path_find(const char *name, const H5T_t *src, const H5T_t *dst,
/* Insert */
if (create) {
if (H5T_npath_g >= H5T_apath_g) {
- H5T_apath_g = MAX(64, 2 * H5T_apath_g);
- H5T_path_g = H5MM_xrealloc(H5T_path_g,
- H5T_apath_g * sizeof(H5T_path_t*));
+ size_t na = MAX(64, 2 * H5T_apath_g);
+ H5T_path_t **x = H5MM_realloc (H5T_path_g,
+ na*sizeof(H5T_path_t*));
+ if (!x) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
+ H5T_apath_g = na;
+ H5T_path_g = x;
}
if (cmp > 0) md++;
@@ -4161,7 +4208,10 @@ H5T_path_find(const char *name, const H5T_t *src, const H5T_t *dst,
H5T_npath_g++;
/* insert */
- path = H5T_path_g[md] = H5MM_xcalloc (1, sizeof(H5T_path_t));
+ if (NULL==(path=H5T_path_g[md]=H5MM_calloc (sizeof(H5T_path_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
path->src = H5T_copy(src, H5T_COPY_ALL);
path->dst = H5T_copy(dst, H5T_COPY_ALL);
@@ -4172,7 +4222,10 @@ H5T_path_find(const char *name, const H5T_t *src, const H5T_t *dst,
path->func = func;
path->is_hard = TRUE;
path->cdata.command = H5T_CONV_INIT;
- path->cdata.stats = H5MM_xcalloc (1, sizeof(H5T_stats_t));
+ if (NULL==(path->cdata.stats=H5MM_calloc(sizeof(H5T_stats_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
if ((src_id=H5I_register(H5_DATATYPE,
H5T_copy(path->src, H5T_COPY_ALL))) < 0 ||
(dst_id=H5I_register(H5_DATATYPE,
@@ -4206,7 +4259,11 @@ H5T_path_find(const char *name, const H5T_t *src, const H5T_t *dst,
"unable to register conv types for query");
}
path->cdata.command = H5T_CONV_INIT;
- path->cdata.stats = H5MM_xcalloc (1, sizeof(H5T_stats_t));
+ path->cdata.stats = H5MM_calloc (sizeof(H5T_stats_t));
+ if (NULL==path->cdata.stats) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
if ((H5T_soft_g[i].func) (src_id, dst_id, &(path->cdata),
H5T_CONV_INIT, NULL, NULL) < 0) {
HDmemset (&(path->cdata), 0, sizeof(H5T_cdata_t));
diff --git a/src/H5Tconv.c b/src/H5Tconv.c
index 2d69dc1..f994345 100644
--- a/src/H5Tconv.c
+++ b/src/H5Tconv.c
@@ -215,12 +215,22 @@ H5T_conv_struct_init (H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata)
* `src' because we're only interested in the members of the
* source type that are also in the destination type.
*/
- cdata->priv = priv = H5MM_xcalloc (1, sizeof(H5T_conv_struct_t));
- priv->src2dst = H5MM_xmalloc (src->u.compnd.nmembs * sizeof(intn));
- priv->src_memb_id = H5MM_xmalloc (/*!*/dst->u.compnd.nmembs *
- sizeof(hid_t));
- priv->dst_memb_id = H5MM_xmalloc (dst->u.compnd.nmembs *
- sizeof(hid_t));
+ cdata->priv = priv = H5MM_calloc (sizeof(H5T_conv_struct_t));
+ if (NULL==priv) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
+ priv->src2dst = H5MM_malloc (src->u.compnd.nmembs * sizeof(intn));
+ priv->src_memb_id = H5MM_malloc (/*!*/dst->u.compnd.nmembs *
+ sizeof(hid_t));
+ priv->dst_memb_id = H5MM_malloc (dst->u.compnd.nmembs *
+ sizeof(hid_t));
+ if (NULL==priv->src2dst ||
+ NULL==priv->src_memb_id ||
+ NULL==priv->dst_memb_id) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
/*
* Insure that members are sorted.
@@ -265,10 +275,14 @@ H5T_conv_struct_init (H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata)
*/
priv->memb_conv = H5MM_xfree (priv->memb_conv);
priv->memb_cdata = H5MM_xfree (priv->memb_cdata);
- priv->memb_conv = H5MM_xmalloc (dst->u.compnd.nmembs *
- sizeof(H5T_conv_t));
- priv->memb_cdata = H5MM_xcalloc (dst->u.compnd.nmembs,
+ priv->memb_conv = H5MM_malloc (dst->u.compnd.nmembs *
+ sizeof(H5T_conv_t));
+ priv->memb_cdata = H5MM_calloc (dst->u.compnd.nmembs *
sizeof(H5T_cdata_t*));
+ if (NULL==priv->memb_conv || NULL==priv->memb_cdata) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
src2dst = priv->src2dst;
for (i=0; i<src->u.compnd.nmembs; i++) {
diff --git a/src/H5detect.c b/src/H5detect.c
index 119822c..b429caf 100644
--- a/src/H5detect.c
+++ b/src/H5detect.c
@@ -362,7 +362,10 @@ H5T_init (void)\n\
/* The part common to fixed and floating types */
printf("\
- dt = H5MM_xcalloc (1, sizeof(H5T_t));\n\
+ if (NULL==(dt = H5MM_calloc (sizeof(H5T_t)))) {\n\
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,\n\
+ \"memory allocation failed\");\n\
+ }\n\
dt->state = H5T_STATE_IMMUTABLE;\n\
H5F_addr_undef (&(dt->ent.header));\n\
dt->type = H5T_%s;\n\
diff --git a/test/.distdep b/test/.distdep
index 17b11f1..388026c 100644
--- a/test/.distdep
+++ b/test/.distdep
@@ -106,37 +106,6 @@ tstab.o: \
../src/H5Tpublic.h \
../src/H5Sprivate.h \
../src/H5Spublic.h
-hyperslab.o: \
- hyperslab.c \
- ../src/H5private.h \
- ../src/H5public.h \
- ../src/H5config.h
-istore.o: \
- istore.c \
- ../src/H5private.h \
- ../src/H5public.h \
- ../src/H5config.h \
- ../src/H5Iprivate.h \
- ../src/H5Ipublic.h \
- ../src/H5Pprivate.h \
- ../src/H5Ppublic.h \
- ../src/H5Dpublic.h \
- ../src/H5Fpublic.h \
- ../src/H5Zpublic.h \
- ../src/H5Fprivate.h \
- ../src/H5Gprivate.h \
- ../src/H5Gpublic.h \
- ../src/H5Bprivate.h \
- ../src/H5Bpublic.h \
- ../src/H5MMprivate.h \
- ../src/H5MMpublic.h \
- ../src/H5Oprivate.h \
- ../src/H5Opublic.h \
- ../src/H5HGprivate.h \
- ../src/H5HGpublic.h \
- ../src/H5Tprivate.h \
- ../src/H5Tpublic.h \
- ../src/H5Sprivate.h
extend.o: \
extend.c \
../src/hdf5.h \
@@ -302,20 +271,17 @@ bittests.o: \
../src/H5Gprivate.h \
../src/H5Gpublic.h \
../src/H5Bprivate.h
-tattr.o: \
- tattr.c \
- testhdf5.h \
- ../src/H5private.h \
+dtypes.o: \
+ dtypes.c \
+ ../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
- ../src/H5Eprivate.h \
- ../src/H5Epublic.h \
../src/H5Ipublic.h \
- ../src/hdf5.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
../src/H5Bpublic.h \
../src/H5Dpublic.h \
+ ../src/H5Epublic.h \
../src/H5Fpublic.h \
../src/H5Gpublic.h \
../src/H5HGpublic.h \
@@ -325,9 +291,10 @@ tattr.o: \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
- ../src/H5Spublic.h
-dtypes.o: \
- dtypes.c \
+ ../src/H5Spublic.h \
+ ../src/H5Tpublic.h
+dsets.o: \
+ dsets.c \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
@@ -348,8 +315,8 @@ dtypes.o: \
../src/H5Zpublic.h \
../src/H5Spublic.h \
../src/H5Tpublic.h
-dsets.o: \
- dsets.c \
+cmpd_dset.o: \
+ cmpd_dset.c \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
@@ -368,10 +335,9 @@ dsets.o: \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
- ../src/H5Spublic.h \
- ../src/H5Tpublic.h
-cmpd_dset.o: \
- cmpd_dset.c \
+ ../src/H5Spublic.h
+external.o: \
+ external.c \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
@@ -390,18 +356,22 @@ cmpd_dset.o: \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
- ../src/H5Spublic.h
-external.o: \
- external.c \
- ../src/hdf5.h \
+ ../src/H5Spublic.h \
+ ../src/H5Tpublic.h
+tattr.o: \
+ tattr.c \
+ testhdf5.h \
+ ../src/H5private.h \
../src/H5public.h \
../src/H5config.h \
+ ../src/H5Eprivate.h \
+ ../src/H5Epublic.h \
../src/H5Ipublic.h \
+ ../src/hdf5.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
../src/H5Bpublic.h \
../src/H5Dpublic.h \
- ../src/H5Epublic.h \
../src/H5Fpublic.h \
../src/H5Gpublic.h \
../src/H5HGpublic.h \
@@ -411,8 +381,7 @@ external.o: \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
- ../src/H5Spublic.h \
- ../src/H5Tpublic.h
+ ../src/H5Spublic.h
th5s.o: \
th5s.c \
testhdf5.h \
@@ -440,3 +409,34 @@ th5s.o: \
../src/H5Zprivate.h \
../src/H5Zpublic.h \
../src/H5Pprivate.h
+hyperslab.o: \
+ hyperslab.c \
+ ../src/H5private.h \
+ ../src/H5public.h \
+ ../src/H5config.h
+istore.o: \
+ istore.c \
+ ../src/H5private.h \
+ ../src/H5public.h \
+ ../src/H5config.h \
+ ../src/H5Iprivate.h \
+ ../src/H5Ipublic.h \
+ ../src/H5Pprivate.h \
+ ../src/H5Ppublic.h \
+ ../src/H5Dpublic.h \
+ ../src/H5Fpublic.h \
+ ../src/H5Zpublic.h \
+ ../src/H5Fprivate.h \
+ ../src/H5Gprivate.h \
+ ../src/H5Gpublic.h \
+ ../src/H5Bprivate.h \
+ ../src/H5Bpublic.h \
+ ../src/H5MMprivate.h \
+ ../src/H5MMpublic.h \
+ ../src/H5Oprivate.h \
+ ../src/H5Opublic.h \
+ ../src/H5HGprivate.h \
+ ../src/H5HGpublic.h \
+ ../src/H5Tprivate.h \
+ ../src/H5Tpublic.h \
+ ../src/H5Sprivate.h
diff --git a/test/hyperslab.c b/test/hyperslab.c
index b1d3deb..5ca810d 100644
--- a/test/hyperslab.c
+++ b/test/hyperslab.c
@@ -120,7 +120,7 @@ print_ref(size_t nx, size_t ny, size_t nz)
{
uint8 *array;
- array = H5MM_xcalloc((intn)(nx*ny*nz), sizeof(uint8));
+ array = H5MM_calloc(nx*ny*nz*sizeof(uint8));
printf("Reference array:\n");
init_full(array, nx, ny, nz);
@@ -183,7 +183,7 @@ test_fill(size_t nx, size_t ny, size_t nz,
fflush(stdout);
/* Allocate array */
- dst = H5MM_xcalloc(1, nx*ny*nz);
+ dst = H5MM_calloc(nx*ny*nz);
init_full(dst, nx, ny, nz);
for (i = 0; i < nx; i += di) {
@@ -380,8 +380,8 @@ test_copy(int mode,
/*
* Allocate arrays
*/
- src = H5MM_xcalloc(1, nx*ny*nz);
- dst = H5MM_xcalloc(1, nx*ny*nz);
+ src = H5MM_calloc(nx*ny*nz);
+ dst = H5MM_calloc(nx*ny*nz);
init_full(src, nx, ny, nz);
for (i = 0; i < nx; i += di) {
@@ -599,8 +599,8 @@ test_multifill(size_t nx)
fflush(stdout);
/* Initialize the source and destination */
- src = H5MM_xmalloc(nx * sizeof(*src));
- dst = H5MM_xmalloc(nx * sizeof(*dst));
+ src = H5MM_malloc(nx * sizeof(*src));
+ dst = H5MM_malloc(nx * sizeof(*dst));
for (i = 0; i < nx; i++) {
src[i].left = 1111111;
src[i].mid = 12345.6789;
@@ -707,9 +707,9 @@ test_endian(size_t nx)
fflush(stdout);
/* Initialize arrays */
- src = H5MM_xmalloc(nx * 4);
+ src = H5MM_malloc(nx * 4);
init_full(src, nx, 4, 1);
- dst = H5MM_xcalloc(4, nx);
+ dst = H5MM_calloc(nx * 4);
/* Initialize strides */
src_stride[0] = 0;
@@ -789,13 +789,13 @@ test_transpose(size_t nx, size_t ny)
fflush(stdout);
/* Initialize */
- src = H5MM_xmalloc(nx * ny * sizeof(*src));
+ src = H5MM_malloc(nx * ny * sizeof(*src));
for (i = 0; i < nx; i++) {
for (j = 0; j < ny; j++) {
src[i * ny + j] = (intn)(i * ny + j);
}
}
- dst = H5MM_xcalloc((intn)(nx*ny), sizeof(*dst));
+ dst = H5MM_calloc(nx*ny*sizeof(*dst));
/* Build stride info */
size[0] = nx;
@@ -896,10 +896,10 @@ test_sub_super(size_t nx, size_t ny)
fflush(stdout);
/* Initialize */
- full = H5MM_xmalloc(4 * nx * ny);
+ full = H5MM_malloc(4 * nx * ny);
init_full(full, 2 * nx, 2 * ny, 1);
- half = H5MM_xcalloc(1, nx*ny);
- twice = H5MM_xcalloc(1, 4*nx*ny);
+ half = H5MM_calloc(nx*ny);
+ twice = H5MM_calloc(4*nx*ny);
/* Setup */
size[0] = nx;
diff --git a/test/istore.c b/test/istore.c
index 06b13be..24c5cd7 100644
--- a/test/istore.c
+++ b/test/istore.c
@@ -236,9 +236,9 @@ test_extend(H5F_t *f, const char *prefix,
sprintf(s, "Testing istore extend: %s", dims);
printf("%-70s", s);
- buf = H5MM_xmalloc(nx * ny * nz);
- check = H5MM_xmalloc(nx * ny * nz);
- whole = H5MM_xcalloc(1, nx*ny*nz);
+ buf = H5MM_malloc(nx * ny * nz);
+ check = H5MM_malloc(nx * ny * nz);
+ whole = H5MM_calloc(nx*ny*nz);
/* Build the new empty object */
sprintf(name, "%s_%s", prefix, dims);
@@ -460,7 +460,7 @@ test_sparse(H5F_t *f, const char *prefix, size_t nblocks,
sprintf(s, "Testing istore sparse: %s", dims);
printf("%-70s", s);
- buf = H5MM_xmalloc(nx * ny * nz);
+ buf = H5MM_malloc(nx * ny * nz);
/* Build the new empty object */
sprintf(name, "%s_%s", prefix, dims);