diff options
author | Robb Matzke <matzke@llnl.gov> | 1998-06-23 03:41:22 (GMT) |
---|---|---|
committer | Robb Matzke <matzke@llnl.gov> | 1998-06-23 03:41:22 (GMT) |
commit | 4bf629adc96541fda24bafbdde00fd4ff92be344 (patch) | |
tree | 8e6d57995ba50bafdf172df9d480bd99cdb1230e /src/H5P.c | |
parent | 62607debf74800472572e65517ed284aef19a63c (diff) | |
download | hdf5-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.
Diffstat (limited to 'src/H5P.c')
-rw-r--r-- | src/H5P.c | 51 |
1 files changed, 39 insertions, 12 deletions
@@ -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]; |