diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 1998-10-26 17:23:29 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 1998-10-26 17:23:29 (GMT) |
commit | 808847e0a1f5671c61e51455e8d6314d83341fef (patch) | |
tree | 701dfc48605ba7d3119b2cfbdbdc31401363d064 /src | |
parent | 5ff842ebefb4adcebaaecd5b6809f32f614ed932 (diff) | |
download | hdf5-808847e0a1f5671c61e51455e8d6314d83341fef.zip hdf5-808847e0a1f5671c61e51455e8d6314d83341fef.tar.gz hdf5-808847e0a1f5671c61e51455e8d6314d83341fef.tar.bz2 |
[svn-r791] Internal API tweaks to H5D_open_oid
Diffstat (limited to 'src')
-rw-r--r-- | src/H5D.c | 51 | ||||
-rw-r--r-- | src/H5Dprivate.h | 3 | ||||
-rw-r--r-- | src/H5R.c | 8 |
3 files changed, 29 insertions, 33 deletions
@@ -96,6 +96,7 @@ static hbool_t interface_initialize_g = FALSE; static herr_t H5D_init_interface(void); static void H5D_term_interface(void); static herr_t H5D_init_storage(H5D_t *dataset, const H5S_t *space); +H5D_t * H5D_new(const H5D_create_t *create_parms); /*-------------------------------------------------------------------------- @@ -1137,6 +1138,7 @@ H5D_open(H5G_entry_t *loc, const char *name) { H5D_t *dataset = NULL; /*the dataset which was found */ H5D_t *ret_value = NULL; /*return value */ + H5G_entry_t ent; /* Dataset symbol table entry */ FUNC_ENTER(H5D_open, NULL); @@ -1144,17 +1146,12 @@ H5D_open(H5G_entry_t *loc, const char *name) assert (loc); assert (name && *name); - if (NULL==(dataset = H5D_new(NULL))) { - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, - "memory allocation failed"); - } - /* Find the dataset object */ - if (H5G_find(loc, name, NULL, &(dataset->ent)) < 0) { + if (H5G_find(loc, name, NULL, &ent) < 0) { HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, NULL, "not found"); } /* Open the dataset object */ - if (H5D_open_oid(dataset, NULL) < 0) { + if ((dataset=H5D_open_oid(&ent)) ==NULL) { HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, NULL, "not found"); } @@ -1181,34 +1178,40 @@ done: * *------------------------------------------------------------------------- */ -herr_t -H5D_open_oid(H5D_t *dataset, H5G_entry_t *ent) +H5D_t * +H5D_open_oid(H5G_entry_t *ent) { - herr_t ret_value = FAIL; /*return value */ + H5D_t *dataset = NULL; /* New dataset struct */ + H5D_t *ret_value = NULL; /*return value */ intn i; H5S_t *space = NULL; - FUNC_ENTER(H5D_open_oid, FAIL); + FUNC_ENTER(H5D_open_oid, NULL); /* check args */ - assert (dataset); + assert (ent); + /* Allocate the dataset structure */ + if (NULL==(dataset = H5D_new(NULL))) { + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed"); + } + /* Copy over the symbol table information if it's provided */ - if(ent!=NULL) - HDmemcpy(&(dataset->ent),ent,sizeof(H5G_entry_t)); + HDmemcpy(&(dataset->ent),ent,sizeof(H5G_entry_t)); /* Find the dataset object */ if (H5O_open(&(dataset->ent)) < 0) { - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "unable to open"); } /* Get the type and space */ if (NULL==(dataset->type=H5O_read(&(dataset->ent), H5O_DTYPE, 0, NULL))) { - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to load type info from dataset header"); } if (NULL==(space=H5S_read (&(dataset->ent)))) { - HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, "unable to read data space info from dataset header"); } @@ -1232,7 +1235,7 @@ H5D_open_oid(H5D_t *dataset, H5G_entry_t *ent) /* If MPIO is used, no filter support yet. */ if (dataset->ent.file->shared->access_parms->driver == H5F_LOW_MPIO && dataset->create_parms->pline.nfilters>0){ - HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL, + HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, NULL, "Parallel IO does not support filters yet"); } #endif @@ -1244,7 +1247,7 @@ H5D_open_oid(H5D_t *dataset, H5G_entry_t *ent) * them. */ if (NULL==H5O_read(&(dataset->ent), H5O_LAYOUT, 0, &(dataset->layout))) { - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to read data layout message"); } switch (dataset->layout.type) { @@ -1266,7 +1269,7 @@ H5D_open_oid(H5D_t *dataset, H5G_entry_t *ent) break; default: - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "not implemented yet"); } @@ -1274,7 +1277,7 @@ H5D_open_oid(H5D_t *dataset, H5G_entry_t *ent) if (NULL==H5O_read (&(dataset->ent), H5O_EFL, 0, &(dataset->create_parms->efl)) && !H5F_addr_defined (&(dataset->layout.addr))) { - HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, "storage address is undefined an no external file list"); } @@ -1286,18 +1289,18 @@ H5D_open_oid(H5D_t *dataset, H5G_entry_t *ent) if ((dataset->ent.file->intent & H5F_ACC_RDWR) && H5D_CHUNKED==dataset->layout.type) { if (H5D_init_storage(dataset, space)<0) { - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize file storage"); } } /* Success */ - ret_value = SUCCEED; + ret_value = dataset; done: if (space) H5S_close (space); - if (ret_value<0 && dataset) { + if (ret_value==NULL && dataset) { if (H5F_addr_defined(&(dataset->ent.header))) { H5O_close(&(dataset->ent)); } diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h index 6aeb421..bdf66f7 100644 --- a/src/H5Dprivate.h +++ b/src/H5Dprivate.h @@ -81,8 +81,7 @@ herr_t H5D_extend (H5D_t *dataset, const hsize_t *size); H5G_entry_t *H5D_entof (H5D_t *dataset); H5T_t *H5D_typeof (H5D_t *dset); H5S_t *H5D_get_space(H5D_t *dset); -H5D_t * H5D_new(const H5D_create_t *create_parms); -herr_t H5D_open_oid(H5D_t *dataset, H5G_entry_t *ent); +H5D_t * H5D_open_oid(H5G_entry_t *ent); H5F_t * H5D_get_file(const H5D_t *dset); #endif @@ -267,12 +267,6 @@ H5R_dereference(H5D_t *dset, H5R_type_t ref_type, void *_ref) * Switch on object type, when we implement that feature, always try to * open a dataset for now */ - /* Allocate the dataset structure */ - if (NULL==(dataset = H5D_new(NULL))) { - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, - "memory allocation failed"); - } - /* Initialize the symbol table entry */ HDmemset(&ent,0,sizeof(H5G_entry_t)); ent.type=H5G_NOTHING_CACHED; @@ -281,7 +275,7 @@ H5R_dereference(H5D_t *dset, H5R_type_t ref_type, void *_ref) H5F_addr_decode(ent.file,(const uint8 **)&p,&(ent.header)); /* Open the dataset object */ - if (H5D_open_oid(dataset, &ent) < 0) { + if ((dataset=H5D_open_oid(&ent)) == NULL) { HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "not found"); } |