summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-08-23 20:56:42 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-08-23 20:56:42 (GMT)
commit0f95a9d5ab47a609f50c7554e46f60b625df07e8 (patch)
tree2137e981bc20f6e3f40176487780a9032936d228 /src
parent65996f2921391c653d05ad92b7b62ba27f3c2bdd (diff)
downloadhdf5-0f95a9d5ab47a609f50c7554e46f60b625df07e8.zip
hdf5-0f95a9d5ab47a609f50c7554e46f60b625df07e8.tar.gz
hdf5-0f95a9d5ab47a609f50c7554e46f60b625df07e8.tar.bz2
[svn-r19278] Description:
More fixes to memory allocation, etc. exposed by valgrind. Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, w/threadsafe, in production mode Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode Mac OS X/32 10.6.4 (amazon) in debug mode Mac OS X/32 10.6.4 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode Mac OS X/32 10.6.4 (amazon) w/parallel, in debug mode
Diffstat (limited to 'src')
-rw-r--r--src/H5Dfill.c3
-rw-r--r--src/H5F.c8
-rw-r--r--src/H5Gdeprec.c4
-rw-r--r--src/H5Gnode.c12
-rw-r--r--src/H5Gtraverse.c14
-rw-r--r--src/H5HLcache.c14
-rw-r--r--src/H5Omtime.c43
7 files changed, 63 insertions, 35 deletions
diff --git a/src/H5Dfill.c b/src/H5Dfill.c
index cf78b94..4474661 100644
--- a/src/H5Dfill.c
+++ b/src/H5Dfill.c
@@ -585,7 +585,8 @@ H5D_fill_refill_vl(H5D_fill_buf_info_t *fb_info, size_t nelmts, hid_t dxpl_id)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "data type conversion failed")
/* Replicate the fill value into the cached buffer */
- H5V_array_fill((void *)((unsigned char *)fb_info->fill_buf + fb_info->mem_elmt_size), fb_info->fill_buf, fb_info->mem_elmt_size, (nelmts - 1));
+ if(nelmts > 1)
+ H5V_array_fill((void *)((unsigned char *)fb_info->fill_buf + fb_info->mem_elmt_size), fb_info->fill_buf, fb_info->mem_elmt_size, (nelmts - 1));
/* Reset the entire background buffer, if necessary */
if(H5T_path_bkg(fb_info->mem_to_dset_tpath))
diff --git a/src/H5F.c b/src/H5F.c
index f1a4b0c..f15a0cd 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -1198,16 +1198,24 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id,
if(NULL == (lf = H5FD_open(name, tent_flags, fapl_id, HADDR_UNDEF))) {
if(tent_flags == flags) {
+#ifndef H5_USING_MEMCHECKER
time_t mytime = HDtime(NULL);
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: time = %s, name = '%s', tent_flags = %x", HDctime(&mytime), name, tent_flags)
+#else /* H5_USING_MEMCHECKER */
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: name = '%s', tent_flags = %x", name, tent_flags)
+#endif /* H5_USING_MEMCHECKER */
} /* end if */
H5E_clear_stack(NULL);
tent_flags = flags;
if(NULL == (lf = H5FD_open(name, tent_flags, fapl_id, HADDR_UNDEF))) {
+#ifndef H5_USING_MEMCHECKER
time_t mytime = HDtime(NULL);
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: time = %s, name = '%s', tent_flags = %x", HDctime(&mytime), name, tent_flags)
+#else /* H5_USING_MEMCHECKER */
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: name = '%s', tent_flags = %x", name, tent_flags)
+#endif /* H5_USING_MEMCHECKER */
} /* end if */
} /* end if */
diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c
index e9e124f..6629934 100644
--- a/src/H5Gdeprec.c
+++ b/src/H5Gdeprec.c
@@ -1142,7 +1142,7 @@ H5G_obj_get_type_by_idx(H5O_loc_t *oloc, hsize_t idx, hid_t dxpl_id)
htri_t linfo_exists; /* Whether the link info message exists */
H5G_obj_t ret_value; /* Return value */
- FUNC_ENTER_NOAPI(H5G_obj_get_type_by_idx, H5G_UNKNOWN)
+ FUNC_ENTER_NOAPI_TAG(H5G_obj_get_type_by_idx, dxpl_id, oloc->addr, H5G_UNKNOWN)
/* Sanity check */
HDassert(oloc);
@@ -1169,7 +1169,7 @@ H5G_obj_get_type_by_idx(H5O_loc_t *oloc, hsize_t idx, hid_t dxpl_id)
} /* end else */
done:
- FUNC_LEAVE_NOAPI(ret_value)
+ FUNC_LEAVE_NOAPI_TAG(ret_value, H5G_UNKNOWN)
} /* end H5G_obj_get_type_by_idx() */
#endif /* H5_NO_DEPRECATED_SYMBOLS */
diff --git a/src/H5Gnode.c b/src/H5Gnode.c
index fb07c63..2b793a9 100644
--- a/src/H5Gnode.c
+++ b/src/H5Gnode.c
@@ -778,7 +778,7 @@ H5G_node_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key/*in,out*/,
/* "Normal" removal of a single entry from the symbol table node */
if(udata->common.name != NULL) {
H5O_link_t lnk; /* Constructed link for replacement */
- size_t len; /* Length of string in local heap */
+ size_t link_name_len; /* Length of string in local heap */
const char *base; /* Base of heap */
/* Get base address of heap */
@@ -804,6 +804,7 @@ H5G_node_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key/*in,out*/,
/* Get a pointer to the name of the link */
if(NULL == (lnk.name = (char *)H5HL_offset_into(udata->common.heap, sn->entry[idx].name_off)))
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5B_INS_ERROR, "unable to get link name")
+ link_name_len = HDstrlen(lnk.name) + 1;
/* Set up rest of link structure */
lnk.corder_valid = FALSE;
@@ -837,15 +838,16 @@ H5G_node_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key/*in,out*/,
else {
/* Remove the soft link's value from the local heap */
if(lnk.u.soft.name) {
- len = HDstrlen(lnk.u.soft.name) + 1;
- if(H5HL_remove(f, dxpl_id, udata->common.heap, sn->entry[idx].cache.slink.lval_offset, len) < 0)
+ size_t soft_link_len; /* Length of string in local heap */
+
+ soft_link_len = HDstrlen(lnk.u.soft.name) + 1;
+ if(H5HL_remove(f, dxpl_id, udata->common.heap, sn->entry[idx].cache.slink.lval_offset, soft_link_len) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, H5B_INS_ERROR, "unable to remove soft link from local heap")
} /* end if */
} /* end else */
/* Remove the link's name from the local heap */
- len = HDstrlen(lnk.name) + 1;
- if(H5HL_remove(f, dxpl_id, udata->common.heap, sn->entry[idx].name_off, len) < 0)
+ if(H5HL_remove(f, dxpl_id, udata->common.heap, sn->entry[idx].name_off, link_name_len) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, H5B_INS_ERROR, "unable to remove link name from local heap")
/* Remove the entry from the symbol table node */
diff --git a/src/H5Gtraverse.c b/src/H5Gtraverse.c
index 61c08fa..742e2bc 100644
--- a/src/H5Gtraverse.c
+++ b/src/H5Gtraverse.c
@@ -807,6 +807,17 @@ H5G_traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target,
if(grp_loc.oloc->holding_file)
if(H5O_loc_hold_file(obj_loc.oloc) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to hold file open")
+
+ /* Reset any non-default object header messages */
+ if(ginfo != &def_ginfo)
+ if(H5O_msg_reset(H5O_GINFO_ID, ginfo) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to reset group info message")
+ if(linfo != &def_linfo)
+ if(H5O_msg_reset(H5O_LINFO_ID, linfo) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to reset link info message")
+ if(pline != &def_pline)
+ if(H5O_msg_reset(H5O_PLINE_ID, pline) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to reset I/O pipeline message")
} /* end if */
else
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "component not found")
@@ -857,7 +868,8 @@ done:
/* If there's valid information in the link, reset it */
if(link_valid)
- H5O_msg_reset(H5O_LINK_ID, &lnk);
+ if(H5O_msg_reset(H5O_LINK_ID, &lnk) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to reset link message")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_traverse_real() */
diff --git a/src/H5HLcache.c b/src/H5HLcache.c
index 51d60f9..56d9919 100644
--- a/src/H5HLcache.c
+++ b/src/H5HLcache.c
@@ -440,10 +440,16 @@ H5HL_prefix_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr,
/* Check if the local heap is a single object in cache */
if(heap->single_cache_obj) {
- /* Set p to the start of the data block. This is necessary because
- * there may be a gap between the used portion of the prefix and the
- * data block due to alignment constraints. */
- p = buf + heap->prfx_size;
+ if((p - buf) < heap->prfx_size) {
+ size_t gap; /* Size of gap between prefix and data block */
+
+ /* Set p to the start of the data block. This is necessary because
+ * there may be a gap between the used portion of the prefix and the
+ * data block due to alignment constraints. */
+ gap = heap->prfx_size - (p - buf);
+ HDmemset(p, 0, gap);
+ p += gap;
+ } /* end if */
/* Serialize the free list into the heap data's image */
H5HL_fl_serialize(heap);
diff --git a/src/H5Omtime.c b/src/H5Omtime.c
index e71fb50..731d833 100644
--- a/src/H5Omtime.c
+++ b/src/H5Omtime.c
@@ -96,7 +96,7 @@ const H5O_msg_class_t H5O_MSG_MTIME_NEW[1] = {{
#define H5O_MTIME_VERSION 1
/* Track whether tzset routine was called */
-static int ntzset=0;
+static hbool_t ntzset = FALSE;
/* Declare a free list to manage the time_t struct */
H5FL_DEFINE(time_t);
@@ -180,23 +180,22 @@ H5O_mtime_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, H5O_t UNUSED *open_oh,
struct tm tm;
void *ret_value; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5O_mtime_decode);
+ FUNC_ENTER_NOAPI_NOINIT(H5O_mtime_decode)
/* check args */
- assert(f);
- assert(p);
+ HDassert(f);
+ HDassert(p);
/* Initialize time zone information */
- if (!ntzset) {
+ if(!ntzset) {
HDtzset();
- ntzset=1;
+ ntzset = TRUE;
} /* end if */
/* decode */
- for (i=0; i<14; i++) {
- if (!HDisdigit(p[i]))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "badly formatted modification time message");
- }
+ for(i = 0; i < 14; i++)
+ if(!HDisdigit(p[i]))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "badly formatted modification time message")
/*
* Convert YYYYMMDDhhmmss UTC to a time_t. This is a little problematic
@@ -213,8 +212,8 @@ H5O_mtime_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, H5O_t UNUSED *open_oh,
tm.tm_min = (p[10]-'0')*10 + (p[11]-'0');
tm.tm_sec = (p[12]-'0')*10 + (p[13]-'0');
tm.tm_isdst = -1; /*figure it out*/
- if ((time_t)-1==(the_time=HDmktime(&tm)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "badly formatted modification time message");
+ if((time_t)-1 == (the_time = HDmktime(&tm)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "badly formatted modification time message")
#if defined(H5_HAVE_TM_GMTOFF)
/* FreeBSD, OSF 4.0 */
@@ -230,8 +229,8 @@ H5O_mtime_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, H5O_t UNUSED *open_oh,
{
struct timezone tz;
- if (HDBSDgettimeofday(NULL, &tz)<0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to obtain local timezone information");
+ if(HDBSDgettimeofday(NULL, &tz) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to obtain local timezone information")
the_time -= tz.tz_minuteswest * 60 - (tm.tm_isdst ? 3600 : 0);
}
#elif defined(H5_HAVE_GETTIMEOFDAY) && defined(H5_HAVE_STRUCT_TIMEZONE) && defined(H5_GETTIMEOFDAY_GIVES_TZ)
@@ -239,8 +238,8 @@ H5O_mtime_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, H5O_t UNUSED *open_oh,
struct timezone tz;
struct timeval tv; /* Used as a placebo; some systems don't like NULL */
- if (HDgettimeofday(&tv, &tz) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to obtain local timezone information");
+ if(HDgettimeofday(&tv, &tz) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to obtain local timezone information")
the_time -= tz.tz_minuteswest * 60 - (tm.tm_isdst ? 3600 : 0);
}
@@ -254,20 +253,20 @@ H5O_mtime_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, H5O_t UNUSED *open_oh,
*/
/* Irix64 */
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to obtain local timezone information");
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to obtain local timezone information")
#endif
/* The return value */
- if (NULL==(mesg = H5FL_MALLOC(time_t)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ if(NULL == (mesg = H5FL_MALLOC(time_t)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
*mesg = the_time;
/* Set return value */
- ret_value=mesg;
+ ret_value = mesg;
done:
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_mtime_decode() */
/*-------------------------------------------------------------------------