diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2020-10-01 15:29:53 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2020-10-01 15:29:53 (GMT) |
commit | ec8ad09125032c9c232878d02e90aa86df162841 (patch) | |
tree | 5d63105d3a0db7d5bbee41c5b74b097649a2115e /src/H5Ocache_image.c | |
parent | 453238e90e1574ef1c15e3c79f7fb3d77920e77c (diff) | |
download | hdf5-ec8ad09125032c9c232878d02e90aa86df162841.zip hdf5-ec8ad09125032c9c232878d02e90aa86df162841.tar.gz hdf5-ec8ad09125032c9c232878d02e90aa86df162841.tar.bz2 |
Source formatted
Diffstat (limited to 'src/H5Ocache_image.c')
-rw-r--r-- | src/H5Ocache_image.c | 145 |
1 files changed, 64 insertions, 81 deletions
diff --git a/src/H5Ocache_image.c b/src/H5Ocache_image.c index d9b926f..b93ef57 100644 --- a/src/H5Ocache_image.c +++ b/src/H5Ocache_image.c @@ -26,61 +26,55 @@ *------------------------------------------------------------------------- */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Opkg.h" /* Object headers */ -#include "H5MFprivate.h" /* File space management */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Opkg.h" /* Object headers */ +#include "H5MFprivate.h" /* File space management */ /* Callbacks for message class */ -static void *H5O__mdci_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, - unsigned *ioflags, size_t p_size, const uint8_t *p); -static herr_t H5O__mdci_encode(H5F_t *f, hbool_t disable_shared, - uint8_t *p, const void *_mesg); -static void *H5O__mdci_copy(const void *_mesg, void *_dest); -static size_t H5O__mdci_size(const H5F_t *f, hbool_t disable_shared, - const void *_mesg); +static void *H5O__mdci_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size, + const uint8_t *p); +static herr_t H5O__mdci_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); +static void * H5O__mdci_copy(const void *_mesg, void *_dest); +static size_t H5O__mdci_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); static herr_t H5O__mdci_free(void *mesg); static herr_t H5O__mdci_delete(H5F_t *f, H5O_t *open_oh, void *_mesg); -static herr_t H5O__mdci_debug(H5F_t *f, const void *_mesg, FILE *stream, - int indent, int fwidth); +static herr_t H5O__mdci_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* This message derives from H5O message class */ const H5O_msg_class_t H5O_MSG_MDCI[1] = {{ - H5O_MDCI_MSG_ID, /* message id number */ - "mdci", /* message name for debugging */ - sizeof(H5O_mdci_t), /* native message size */ - 0, /* messages are sharable? */ - H5O__mdci_decode, /* decode message */ - H5O__mdci_encode, /* encode message */ - H5O__mdci_copy, /* copy method */ - H5O__mdci_size, /* size of mdc image message */ - NULL, /* reset method */ - H5O__mdci_free, /* free method */ - H5O__mdci_delete, /* file delete method */ - NULL, /* link method */ - NULL, /* set share method */ - NULL, /* can share method */ - NULL, /* pre copy native value to file */ - NULL, /* copy native value to file */ - NULL, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__mdci_debug /* debugging */ + H5O_MDCI_MSG_ID, /* message id number */ + "mdci", /* message name for debugging */ + sizeof(H5O_mdci_t), /* native message size */ + 0, /* messages are sharable? */ + H5O__mdci_decode, /* decode message */ + H5O__mdci_encode, /* encode message */ + H5O__mdci_copy, /* copy method */ + H5O__mdci_size, /* size of mdc image message */ + NULL, /* reset method */ + H5O__mdci_free, /* free method */ + H5O__mdci_delete, /* file delete method */ + NULL, /* link method */ + NULL, /* set share method */ + NULL, /* can share method */ + NULL, /* pre copy native value to file */ + NULL, /* copy native value to file */ + NULL, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__mdci_debug /* debugging */ }}; /* Only one version of the metadata cache image message at present */ -#define H5O_MDCI_VERSION_0 0 +#define H5O_MDCI_VERSION_0 0 /* Declare the free list for H5O_mdci_t's */ H5FL_DEFINE(H5O_mdci_t); - - /*------------------------------------------------------------------------- * Function: H5O__mdci_decode * @@ -96,12 +90,11 @@ H5FL_DEFINE(H5O_mdci_t); *------------------------------------------------------------------------- */ static void * -H5O__mdci_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, - unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, - size_t H5_ATTR_UNUSED p_size, const uint8_t *p) +H5O__mdci_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, + unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { - H5O_mdci_t *mesg; /* Native message */ - void *ret_value = NULL; /* Return value */ + H5O_mdci_t *mesg; /* Native message */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -110,12 +103,13 @@ H5O__mdci_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(p); /* Version of message */ - if(*p++ != H5O_MDCI_VERSION_0) + if (*p++ != H5O_MDCI_VERSION_0) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for message") /* Allocate space for message */ - if(NULL == (mesg = (H5O_mdci_t *)H5FL_MALLOC(H5O_mdci_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for metadata cache image message") + if (NULL == (mesg = (H5O_mdci_t *)H5FL_MALLOC(H5O_mdci_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for metadata cache image message") /* Decode */ H5F_addr_decode(f, &p, &(mesg->addr)); @@ -128,7 +122,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__mdci_decode() */ - /*------------------------------------------------------------------------- * Function: H5O__mdci_encode * @@ -142,8 +135,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__mdci_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, - uint8_t *p, const void *_mesg) +H5O__mdci_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) { const H5O_mdci_t *mesg = (const H5O_mdci_t *)_mesg; @@ -162,7 +154,6 @@ H5O__mdci_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__mdci_encode() */ - /*------------------------------------------------------------------------- * Function: H5O__mdci_copy * @@ -180,15 +171,15 @@ H5O__mdci_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, static void * H5O__mdci_copy(const void *_mesg, void *_dest) { - const H5O_mdci_t *mesg = (const H5O_mdci_t *)_mesg; - H5O_mdci_t *dest = (H5O_mdci_t *) _dest; - void *ret_value = NULL; /* Return value */ + const H5O_mdci_t *mesg = (const H5O_mdci_t *)_mesg; + H5O_mdci_t * dest = (H5O_mdci_t *)_dest; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* check args */ HDassert(mesg); - if(!dest && NULL == (dest = H5FL_MALLOC(H5O_mdci_t))) + if (!dest && NULL == (dest = H5FL_MALLOC(H5O_mdci_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* copy */ @@ -201,7 +192,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_mdci__copy() */ - /*------------------------------------------------------------------------- * Function: H5O__mdci_size * @@ -219,24 +209,22 @@ done: *------------------------------------------------------------------------- */ static size_t -H5O__mdci_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, - const void H5_ATTR_UNUSED *_mesg) +H5O__mdci_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void H5_ATTR_UNUSED *_mesg) { - size_t ret_value = 0; /* Return value */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Set return value */ - ret_value = (size_t)( 1 + /* Version number */ - H5F_SIZEOF_ADDR(f) + /* addr of metadata cache */ - /* image block */ - H5F_SIZEOF_SIZE(f) ); /* length of metadata cache */ - /* image block */ + ret_value = (size_t)(1 + /* Version number */ + H5F_SIZEOF_ADDR(f) + /* addr of metadata cache */ + /* image block */ + H5F_SIZEOF_SIZE(f)); /* length of metadata cache */ + /* image block */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__mdci_size() */ - /*------------------------------------------------------------------------- * Function: H5O__mdci_free * @@ -261,7 +249,6 @@ H5O__mdci_free(void *mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__mdci_free() */ - /*------------------------------------------------------------------------- * Function: H5O__mdci_delete * @@ -277,8 +264,8 @@ H5O__mdci_free(void *mesg) static herr_t H5O__mdci_delete(H5F_t *f, H5O_t *open_oh, void *_mesg) { - H5O_mdci_t *mesg = (H5O_mdci_t *)_mesg; - herr_t ret_value = SUCCEED; /* Return value */ + H5O_mdci_t *mesg = (H5O_mdci_t *)_mesg; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -288,7 +275,7 @@ H5O__mdci_delete(H5F_t *f, H5O_t *open_oh, void *_mesg) HDassert(mesg); /* Free file space for cache image */ - if(H5F_addr_defined(mesg->addr)) { + if (H5F_addr_defined(mesg->addr)) { /* The space for the cache image block was allocated directly * from the VFD layer at the end of file. As this was the * last file space allocation before shutdown, the cache image @@ -321,23 +308,22 @@ H5O__mdci_delete(H5F_t *f, H5O_t *open_oh, void *_mesg) * before the first metadata cache access. However, given * time constraints, I don't want to go there now. */ - if(H5F_FIRST_ALLOC_DEALLOC(f)) { + if (H5F_FIRST_ALLOC_DEALLOC(f)) { HDassert(HADDR_UNDEF != H5F_EOA_PRE_FSM_FSALLOC(f)); HDassert(H5F_addr_ge(mesg->addr, H5F_EOA_PRE_FSM_FSALLOC(f))); - if(H5MF_tidy_self_referential_fsm_hack(f) < 0) + if (H5MF_tidy_self_referential_fsm_hack(f) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "tidy of self referential fsm hack failed") } /* end if */ else { - if(H5MF_xfree(f, H5FD_MEM_SUPER, mesg->addr, mesg->size) < 0) + if (H5MF_xfree(f, H5FD_MEM_SUPER, mesg->addr, mesg->size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free file space for cache image block") } /* end else */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__mdci_delete() */ - /*------------------------------------------------------------------------- * Function: H5O__mdci_debug * @@ -351,10 +337,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__mdci_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, - int indent, int fwidth) +H5O__mdci_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int indent, int fwidth) { - const H5O_mdci_t *mdci = (const H5O_mdci_t *) _mesg; + const H5O_mdci_t *mdci = (const H5O_mdci_t *)_mesg; FUNC_ENTER_STATIC_NOERR @@ -365,12 +350,10 @@ H5O__mdci_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, HDassert(indent >= 0); HDassert(fwidth >= 0); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Metadata Cache Image Block address:", mdci->addr); + HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Metadata Cache Image Block address:", mdci->addr); HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, "Metadata Cache Image Block size in bytes:", mdci->size); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__mdci_debug() */ - |