From 2d3c7c457e6f22a809af0f05344069acdcd92c8f Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 12 Nov 2003 15:46:04 -0500 Subject: [svn-r7837] Purpose: Bug fix. Description: Skip over situation where malloc(0) might occur. Platforms tested: IBM p690 (copper) too minor to require h5committest --- src/H5D.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/H5D.c b/src/H5D.c index bffa6b4..ecab019 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -3382,18 +3382,21 @@ H5D_flush(H5F_t *f, hid_t dxpl_id) if((num_dsets=H5F_get_obj_count(f, H5F_OBJ_DATASET))<0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to get dataset count"); - if(NULL==(id_list=H5MM_malloc(num_dsets*sizeof(hid_t)))) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to allocate memory for ID list"); - if(H5F_get_obj_ids(f, H5F_OBJ_DATASET, -1, id_list)<0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to get dataset ID list"); - for(j=0; jlayout.type==H5D_COMPACT && dataset->layout.dirty) - if(H5O_modify(&(dataset->ent), H5O_LAYOUT_ID, 0, 0, 1, &(dataset->layout), dxpl_id)<0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to update layout message"); - dataset->layout.dirty = FALSE; - } + /* check for something to do */ + if(num_dsets>0) { + if(NULL==(id_list=H5MM_malloc(num_dsets*sizeof(hid_t)))) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to allocate memory for ID list"); + if(H5F_get_obj_ids(f, H5F_OBJ_DATASET, -1, id_list)<0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to get dataset ID list"); + for(j=0; jlayout.type==H5D_COMPACT && dataset->layout.dirty) + if(H5O_modify(&(dataset->ent), H5O_LAYOUT_ID, 0, 0, 1, &(dataset->layout), dxpl_id)<0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to update layout message"); + dataset->layout.dirty = FALSE; + } + } /* end if */ done: if(id_list!=NULL) -- cgit v0.12