diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2005-11-07 03:13:53 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2005-11-07 03:13:53 (GMT) |
commit | 08910385629d5cbfde5aa43cef0bcba17f7995b1 (patch) | |
tree | c47c355e63c972adac3e025e6bdd4a4dc67c0a47 /src/H5Oshared.c | |
parent | 23e994958b6190715aefb698b55dad70deb72049 (diff) | |
download | hdf5-08910385629d5cbfde5aa43cef0bcba17f7995b1.zip hdf5-08910385629d5cbfde5aa43cef0bcba17f7995b1.tar.gz hdf5-08910385629d5cbfde5aa43cef0bcba17f7995b1.tar.bz2 |
[svn-r11686] Purpose:
New feature
Description:
Add in baseline "object copy" code from Peter [in the form of a new API
routine: H5Gcopy()]. There's still some work to do (like handling variable-
length datatypes and possibly support for references) and it hasn't been tested
on mounted files yet, but the core functionality is there and working
correctly.
I've also got a set of patches to update the 1.6 branch with tweaks to
keep the branches mostly in sync, but Elena will kill me if I import them
before the 1.6.5 release is out... :-)
Platforms tested:
FreeBSD 4.11 (sleipnir)
h5committested
Diffstat (limited to 'src/H5Oshared.c')
-rw-r--r-- | src/H5Oshared.c | 63 |
1 files changed, 62 insertions, 1 deletions
diff --git a/src/H5Oshared.c b/src/H5Oshared.c index 8a0a291..09f273d 100644 --- a/src/H5Oshared.c +++ b/src/H5Oshared.c @@ -42,6 +42,8 @@ static void *H5O_shared_copy(const void *_mesg, void *_dest, unsigned update_fla static size_t H5O_shared_size (const H5F_t*, const void *_mesg); static herr_t H5O_shared_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link); static herr_t H5O_shared_link(H5F_t *f, hid_t dxpl_id, const void *_mesg); +static void *H5O_shared_copy_file(H5F_t *file_src, void *native_src, + H5F_t *file_dst, hid_t dxpl_id, H5SL_t *map_list, void *udata); static herr_t H5O_shared_debug (H5F_t*, hid_t dxpl_id, const void*, FILE*, int, int); /* This message derives from H5O */ @@ -59,7 +61,9 @@ const H5O_class_t H5O_SHARED[1] = {{ H5O_shared_link, /*link method */ NULL, /*get share method */ NULL, /*set share method */ - H5O_shared_debug, /*debug method */ + H5O_shared_copy_file, /* copy native value to file */ + NULL, /* post copy native value to file */ + H5O_shared_debug /*debug method */ }}; /* Old version, with full symbol table entry as link for object header sharing */ @@ -472,6 +476,63 @@ done: /*------------------------------------------------------------------------- + * Function: H5O_shared_copy_file + * + * Purpose: Copies a message from _MESG to _DEST in file + * + * Return: Success: Ptr to _DEST + * + * Failure: NULL + * + * Programmer: Quincey Koziol + * November 1, 2005 + * + *------------------------------------------------------------------------- + */ +static void * +H5O_shared_copy_file(H5F_t UNUSED *file_src, void *native_src, + H5F_t *file_dst, hid_t dxpl_id, H5SL_t *map_list, void UNUSED *udata) +{ + H5O_shared_t *shared_src = (H5O_shared_t *)native_src; + H5O_shared_t *shared_dst = NULL; + void *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5O_shared_copy_file) + + /* check args */ + HDassert(shared_src); + HDassert(file_dst); + HDassert(map_list); + + /* Allocate space for the destination message */ + if(NULL == (shared_dst = H5MM_malloc(sizeof(H5O_shared_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + + /* Can't handle copying message in global heap currently */ + HDassert(!shared_src->in_gh); + shared_dst->in_gh = FALSE; + + /* Reset group entry for new object */ + H5G_ent_reset(&(shared_dst->u.ent)); + shared_dst->u.ent.file = file_dst; + + /* Copy the shared object from source to destination */ + if(H5O_copy_header_map(&(shared_src->u.ent), &(shared_dst->u.ent), dxpl_id, map_list) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy object") + + /* Set return value */ + ret_value = shared_dst; + +done: + if(!ret_value) + if(shared_dst) + H5MM_xfree(shared_dst); + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5O_shared_copy_file() */ + + +/*------------------------------------------------------------------------- * Function: H5O_shared_debug * * Purpose: Prints debugging info for the message |