diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2009-12-01 18:34:23 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2009-12-01 18:34:23 (GMT) |
commit | a4750dfae7e187f95c4515939968e6fce880efed (patch) | |
tree | 0fc33c6dda70c952d83759c937ff3bf9499aaa86 /src/H5B2hdr.c | |
parent | dfd01b8331fd3173c396c1ec3e6523db8a8adb9e (diff) | |
download | hdf5-a4750dfae7e187f95c4515939968e6fce880efed.zip hdf5-a4750dfae7e187f95c4515939968e6fce880efed.tar.gz hdf5-a4750dfae7e187f95c4515939968e6fce880efed.tar.bz2 |
[svn-r17946] Description:
Bring r17899:17945 from trunk to revise_chunks branch
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 (smirom) 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, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
Mac OS X/32 10.6.2 (amazon) in debug mode
Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
Diffstat (limited to 'src/H5B2hdr.c')
-rw-r--r-- | src/H5B2hdr.c | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/src/H5B2hdr.c b/src/H5B2hdr.c index ec46729..f1d5d84 100644 --- a/src/H5B2hdr.c +++ b/src/H5B2hdr.c @@ -108,7 +108,7 @@ H5FL_SEQ_DEFINE(H5B2_node_info_t); */ herr_t H5B2_hdr_init(H5F_t *f, H5B2_hdr_t *hdr, const H5B2_create_t *cparam, - uint16_t depth) + void *ctx_udata, uint16_t depth) { size_t sz_max_nrec; /* Temporary variable for range checking */ unsigned u_max_nrec_size; /* Temporary variable for range checking */ @@ -124,6 +124,8 @@ H5B2_hdr_init(H5F_t *f, H5B2_hdr_t *hdr, const H5B2_create_t *cparam, HDassert(hdr); HDassert(cparam); HDassert(cparam->cls); + HDassert((cparam->cls->crt_context && cparam->cls->dst_context) || + (NULL == cparam->cls->crt_context && NULL == cparam->cls->dst_context)); HDassert(cparam->node_size > 0); HDassert(cparam->rrec_size > 0); HDassert(cparam->merge_percent > 0 && cparam->merge_percent <= 100); @@ -149,14 +151,14 @@ H5B2_hdr_init(H5F_t *f, H5B2_hdr_t *hdr, const H5B2_create_t *cparam, /* Allocate "page" for node I/O */ if(NULL == (hdr->page = H5FL_BLK_MALLOC(node_page, hdr->node_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, FAIL, "memory allocation failed") #ifdef H5_CLEAR_MEMORY HDmemset(hdr->page, 0, hdr->node_size); #endif /* H5_CLEAR_MEMORY */ /* Allocate array of node info structs */ if(NULL == (hdr->node_info = H5FL_SEQ_MALLOC(H5B2_node_info_t, (size_t)(hdr->depth + 1)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Initialize leaf node info */ sz_max_nrec = H5B2_NUM_LEAF_REC(hdr->node_size, hdr->rrec_size); @@ -166,13 +168,13 @@ HDmemset(hdr->page, 0, hdr->node_size); hdr->node_info[0].cum_max_nrec = hdr->node_info[0].max_nrec; hdr->node_info[0].cum_max_nrec_size = 0; if(NULL == (hdr->node_info[0].nat_rec_fac = H5FL_fac_init(hdr->cls->nrec_size * hdr->node_info[0].max_nrec))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create node native key block factory") + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't create node native key block factory") hdr->node_info[0].node_ptr_fac = NULL; /* Allocate array of pointers to internal node native keys */ /* (uses leaf # of records because its the largest) */ if(NULL == (hdr->nat_off = H5FL_SEQ_MALLOC(size_t, (size_t)hdr->node_info[0].max_nrec))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Initialize offsets in native key block */ /* (uses leaf # of records because its the largest) */ @@ -201,12 +203,18 @@ HDmemset(hdr->page, 0, hdr->node_size); H5_ASSIGN_OVERFLOW(/* To: */ hdr->node_info[u].cum_max_nrec_size, /* From: */ u_max_nrec_size, /* From: */ unsigned, /* To: */ uint8_t) if(NULL == (hdr->node_info[u].nat_rec_fac = H5FL_fac_init(hdr->cls->nrec_size * hdr->node_info[u].max_nrec))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create node native key block factory") + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't create node native key block factory") if(NULL == (hdr->node_info[u].node_ptr_fac = H5FL_fac_init(sizeof(H5B2_node_ptr_t) * (hdr->node_info[u].max_nrec + 1)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create internal 'branch' node node pointer block factory") + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't create internal 'branch' node node pointer block factory") } /* end for */ } /* end if */ + /* Create the callback context, if the callback exists */ + if(hdr->cls->crt_context) { + if(NULL == (hdr->cb_ctx = (*hdr->cls->crt_context)(ctx_udata))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTCREATE, FAIL, "unable to create v2 B-tree client callback context") + } /* end if */ + done: if(ret_value < 0) if(H5B2_hdr_free(hdr) < 0) @@ -278,7 +286,8 @@ done: *------------------------------------------------------------------------- */ haddr_t -H5B2_hdr_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam) +H5B2_hdr_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, + void *ctx_udata) { H5B2_hdr_t *hdr = NULL; /* The new v2 B-tree header information */ haddr_t ret_value; /* Return value */ @@ -296,7 +305,7 @@ H5B2_hdr_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, HADDR_UNDEF, "allocation failed for B-tree header") /* Initialize shared B-tree info */ - if(H5B2_hdr_init(f, hdr, cparam, (uint16_t)0) < 0) + if(H5B2_hdr_init(f, hdr, cparam, ctx_udata, (uint16_t)0) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, HADDR_UNDEF, "can't create shared B-tree info") /* Allocate space for the header on disk */ @@ -507,6 +516,13 @@ H5B2_hdr_free(H5B2_hdr_t *hdr) /* Sanity check */ HDassert(hdr); + /* Destroy the callback context */ + if(hdr->cb_ctx) { + if((*hdr->cls->dst_context)(hdr->cb_ctx) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "can't destroy v2 B-tree client callback context") + hdr->cb_ctx = NULL; + } /* end if */ + /* Free the B-tree node buffer */ if(hdr->page) (void)H5FL_BLK_FREE(node_page, hdr->page); |