summaryrefslogtreecommitdiffstats
path: root/src/H5WB.c
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2020-10-01 15:29:53 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2020-10-01 15:29:53 (GMT)
commitec8ad09125032c9c232878d02e90aa86df162841 (patch)
tree5d63105d3a0db7d5bbee41c5b74b097649a2115e /src/H5WB.c
parent453238e90e1574ef1c15e3c79f7fb3d77920e77c (diff)
downloadhdf5-ec8ad09125032c9c232878d02e90aa86df162841.zip
hdf5-ec8ad09125032c9c232878d02e90aa86df162841.tar.gz
hdf5-ec8ad09125032c9c232878d02e90aa86df162841.tar.bz2
Source formatted
Diffstat (limited to 'src/H5WB.c')
-rw-r--r--src/H5WB.c63
1 files changed, 25 insertions, 38 deletions
diff --git a/src/H5WB.c b/src/H5WB.c
index abeaf63..f177a9b 100644
--- a/src/H5WB.c
+++ b/src/H5WB.c
@@ -28,54 +28,47 @@
/* Module Setup */
/****************/
-
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5FLprivate.h" /* Free Lists */
-#include "H5WBprivate.h" /* Wrapped Buffers */
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5FLprivate.h" /* Free Lists */
+#include "H5WBprivate.h" /* Wrapped Buffers */
/****************/
/* Local Macros */
/****************/
-
/******************/
/* Local Typedefs */
/******************/
-
/********************/
/* Package Typedefs */
/********************/
/* Typedef for buffer wrapper */
struct H5WB_t {
- void *wrapped_buf; /* Pointer to wrapped buffer */
- size_t wrapped_size; /* Size of wrapped buffer */
- void *actual_buf; /* Pointer to actual buffer */
- size_t actual_size; /* Size of actual buffer used */
- size_t alloc_size; /* Size of actual buffer allocated */
+ void * wrapped_buf; /* Pointer to wrapped buffer */
+ size_t wrapped_size; /* Size of wrapped buffer */
+ void * actual_buf; /* Pointer to actual buffer */
+ size_t actual_size; /* Size of actual buffer used */
+ size_t alloc_size; /* Size of actual buffer allocated */
};
-
/********************/
/* Local Prototypes */
/********************/
-
/*********************/
/* Package Variables */
/*********************/
-
/*****************************/
/* Library Private Variables */
/*****************************/
-
/*******************/
/* Local Variables */
/*******************/
@@ -86,8 +79,6 @@ H5FL_DEFINE_STATIC(H5WB_t);
/* Declare a free list to manage the extra buffer information */
H5FL_BLK_DEFINE_STATIC(extra_buf);
-
-
/*-------------------------------------------------------------------------
* Function: H5WB_wrap
*
@@ -104,8 +95,8 @@ H5FL_BLK_DEFINE_STATIC(extra_buf);
H5WB_t *
H5WB_wrap(void *buf, size_t buf_size)
{
- H5WB_t *wb = NULL; /* Wrapped buffer info */
- H5WB_t *ret_value; /* Return value */
+ H5WB_t *wb = NULL; /* Wrapped buffer info */
+ H5WB_t *ret_value; /* Return value */
FUNC_ENTER_NOAPI(NULL)
@@ -116,30 +107,29 @@ H5WB_wrap(void *buf, size_t buf_size)
HDassert(buf_size);
/* Create wrapped buffer info */
- if(NULL == (wb = H5FL_MALLOC(H5WB_t)))
+ if (NULL == (wb = H5FL_MALLOC(H5WB_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for wrapped buffer info")
/* Wrap buffer given */
- wb->wrapped_buf = buf;
+ wb->wrapped_buf = buf;
wb->wrapped_size = buf_size;
/* No actual buffer yet */
- wb->actual_buf = NULL;
+ wb->actual_buf = NULL;
wb->actual_size = 0;
- wb->alloc_size = 0;
+ wb->alloc_size = 0;
/* Set the return value */
ret_value = wb;
done:
/* Release resources on error */
- if(!ret_value && wb)
+ if (!ret_value && wb)
wb = H5FL_FREE(H5WB_t, wb);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5WB_wrap() */
-
/*-------------------------------------------------------------------------
* Function: H5WB_actual
*
@@ -157,7 +147,7 @@ done:
void *
H5WB_actual(H5WB_t *wb, size_t need)
{
- void *ret_value; /* Return value */
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(NULL)
@@ -168,12 +158,12 @@ H5WB_actual(H5WB_t *wb, size_t need)
HDassert(wb->wrapped_buf);
/* Check for previously allocated buffer */
- if(wb->actual_buf && wb->actual_buf != wb->wrapped_buf) {
+ if (wb->actual_buf && wb->actual_buf != wb->wrapped_buf) {
/* Sanity check */
HDassert(wb->actual_size > wb->wrapped_size);
/* Check if we can re-use existing buffer */
- if(need <= wb->alloc_size)
+ if (need <= wb->alloc_size)
HGOTO_DONE(wb->actual_buf)
/* Can't re-use existing buffer, free it and proceed */
else
@@ -181,9 +171,9 @@ H5WB_actual(H5WB_t *wb, size_t need)
} /* end if */
/* Check if size needed can be fulfilled with wrapped buffer */
- if(need > wb->wrapped_size) {
+ if (need > wb->wrapped_size) {
/* Need to allocate new buffer */
- if(NULL == (wb->actual_buf = H5FL_BLK_MALLOC(extra_buf, need)))
+ if (NULL == (wb->actual_buf = H5FL_BLK_MALLOC(extra_buf, need)))
HGOTO_ERROR(H5E_ATTR, H5E_NOSPACE, NULL, "memory allocation failed")
/* Remember size of buffer allocated */
@@ -200,13 +190,12 @@ H5WB_actual(H5WB_t *wb, size_t need)
done:
/* Remember size of buffer used, if we were successful */
- if(ret_value)
+ if (ret_value)
wb->actual_size = need;
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5WB_actual() */
-
/*-------------------------------------------------------------------------
* Function: H5WB_actual_clear
*
@@ -224,7 +213,7 @@ done:
void *
H5WB_actual_clear(H5WB_t *wb, size_t need)
{
- void *ret_value; /* Return value */
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(NULL)
@@ -235,7 +224,7 @@ H5WB_actual_clear(H5WB_t *wb, size_t need)
HDassert(wb->wrapped_buf);
/* Get a pointer to an actual buffer */
- if(NULL == (ret_value = H5WB_actual(wb, need)))
+ if (NULL == (ret_value = H5WB_actual(wb, need)))
HGOTO_ERROR(H5E_ATTR, H5E_NOSPACE, NULL, "memory allocation failed")
/* Clear the buffer */
@@ -245,7 +234,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5WB_actual_clear() */
-
/*-------------------------------------------------------------------------
* Function: H5WB_unwrap
*
@@ -270,7 +258,7 @@ H5WB_unwrap(H5WB_t *wb)
HDassert(wb->wrapped_buf);
/* Release any extra buffers allocated */
- if(wb->actual_buf && wb->actual_buf != wb->wrapped_buf) {
+ if (wb->actual_buf && wb->actual_buf != wb->wrapped_buf) {
/* Sanity check */
HDassert(wb->actual_size > wb->wrapped_size);
@@ -282,4 +270,3 @@ H5WB_unwrap(H5WB_t *wb)
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5WB_unwrap() */
-