summaryrefslogtreecommitdiffstats
path: root/src/H5RS.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5RS.c')
-rw-r--r--src/H5RS.c70
1 files changed, 28 insertions, 42 deletions
diff --git a/src/H5RS.c b/src/H5RS.c
index 6459f0d..0a62954 100644
--- a/src/H5RS.c
+++ b/src/H5RS.c
@@ -18,16 +18,15 @@
*
*/
-
-#include "H5Eprivate.h" /* Error handling */
-#include "H5FLprivate.h" /* Free lists */
-#include "H5RSprivate.h" /* Reference-counted strings */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5FLprivate.h" /* Free lists */
+#include "H5RSprivate.h" /* Reference-counted strings */
/* Private typedefs & structs */
struct H5RS_str_t {
- char *s; /* String to be reference counted */
- unsigned wrapped; /* Indicates that the string to be ref-counted is not copied */
- unsigned n; /* Reference count of number of pointers sharing string */
+ char * s; /* String to be reference counted */
+ unsigned wrapped; /* Indicates that the string to be ref-counted is not copied */
+ unsigned n; /* Reference count of number of pointers sharing string */
};
/* Declare a free list to manage the H5RS_str_t struct */
@@ -36,7 +35,6 @@ H5FL_DEFINE_STATIC(H5RS_str_t);
/* Declare the PQ free list for the wrapped strings */
H5FL_BLK_DEFINE(str_buf);
-
/*--------------------------------------------------------------------------
NAME
H5RS__xstrdup
@@ -59,11 +57,11 @@ H5FL_BLK_DEFINE(str_buf);
static char *
H5RS__xstrdup(const char *s)
{
- char *ret_value; /* Return value */
+ char *ret_value; /* Return value */
FUNC_ENTER_STATIC_NOERR
- if(s) {
+ if (s) {
size_t len = HDstrlen(s) + 1;
ret_value = (char *)H5FL_BLK_MALLOC(str_buf, len);
@@ -76,7 +74,6 @@ H5RS__xstrdup(const char *s)
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5RS__xstrdup() */
-
/*--------------------------------------------------------------------------
NAME
H5RS_create
@@ -99,24 +96,23 @@ H5RS__xstrdup(const char *s)
H5RS_str_t *
H5RS_create(const char *s)
{
- H5RS_str_t *ret_value; /* Return value */
+ H5RS_str_t *ret_value; /* Return value */
FUNC_ENTER_NOAPI(NULL)
/* Allocate ref-counted string structure */
- if(NULL == (ret_value = H5FL_MALLOC(H5RS_str_t)))
+ if (NULL == (ret_value = H5FL_MALLOC(H5RS_str_t)))
HGOTO_ERROR(H5E_RS, H5E_NOSPACE, NULL, "memory allocation failed")
/* Set the internal fields */
- ret_value->s = H5RS__xstrdup(s);
+ ret_value->s = H5RS__xstrdup(s);
ret_value->wrapped = 0;
- ret_value->n = 1;
+ ret_value->n = 1;
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5RS_create() */
-
/*--------------------------------------------------------------------------
NAME
H5RS_wrap
@@ -139,24 +135,23 @@ done:
H5RS_str_t *
H5RS_wrap(const char *s)
{
- H5RS_str_t *ret_value; /* Return value */
+ H5RS_str_t *ret_value; /* Return value */
FUNC_ENTER_NOAPI(NULL)
/* Allocate ref-counted string structure */
- if(NULL == (ret_value = H5FL_MALLOC(H5RS_str_t)))
+ if (NULL == (ret_value = H5FL_MALLOC(H5RS_str_t)))
HGOTO_ERROR(H5E_RS, H5E_NOSPACE, NULL, "memory allocation failed")
/* Set the internal fields */
- ret_value->s = (char *)s;
+ ret_value->s = (char *)s;
ret_value->wrapped = 1;
- ret_value->n = 1;
+ ret_value->n = 1;
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5RS_wrap() */
-
/*--------------------------------------------------------------------------
NAME
H5RS_own
@@ -181,24 +176,23 @@ done:
H5RS_str_t *
H5RS_own(char *s)
{
- H5RS_str_t *ret_value; /* Return value */
+ H5RS_str_t *ret_value; /* Return value */
FUNC_ENTER_NOAPI(NULL)
/* Allocate ref-counted string structure */
- if(NULL == (ret_value = H5FL_MALLOC(H5RS_str_t)))
+ if (NULL == (ret_value = H5FL_MALLOC(H5RS_str_t)))
HGOTO_ERROR(H5E_RS, H5E_NOSPACE, NULL, "memory allocation failed")
/* Set the internal fields */
- ret_value->s = s;
+ ret_value->s = s;
ret_value->wrapped = 0;
- ret_value->n = 1;
+ ret_value->n = 1;
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5RS_own() */
-
/*--------------------------------------------------------------------------
NAME
H5RS_decr
@@ -228,8 +222,8 @@ H5RS_decr(H5RS_str_t *rs)
HDassert(rs->n > 0);
/* Decrement reference count for string */
- if((--rs->n) == 0) {
- if(!rs->wrapped)
+ if ((--rs->n) == 0) {
+ if (!rs->wrapped)
rs->s = (char *)H5FL_BLK_FREE(str_buf, rs->s);
rs = H5FL_FREE(H5RS_str_t, rs);
} /* end if */
@@ -237,7 +231,6 @@ H5RS_decr(H5RS_str_t *rs)
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5RS_decr() */
-
/*--------------------------------------------------------------------------
NAME
H5RS_incr
@@ -269,8 +262,8 @@ H5RS_incr(H5RS_str_t *rs)
* string, duplicate the string now, so that the wrapped string can go out
* scope appropriately.
*/
- if(rs->wrapped) {
- rs->s = H5RS__xstrdup(rs->s);
+ if (rs->wrapped) {
+ rs->s = H5RS__xstrdup(rs->s);
rs->wrapped = 0;
} /* end if */
@@ -280,7 +273,6 @@ H5RS_incr(H5RS_str_t *rs)
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5RS_incr() */
-
/*--------------------------------------------------------------------------
NAME
H5RS_dup
@@ -306,14 +298,13 @@ H5RS_dup(H5RS_str_t *ret_value)
FUNC_ENTER_NOAPI_NOINIT_NOERR
/* Check for valid reference counted string */
- if(ret_value != NULL)
+ if (ret_value != NULL)
/* Increment reference count for string */
ret_value->n++;
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5RS_dup() */
-
/*--------------------------------------------------------------------------
NAME
H5RS_dup_str
@@ -335,8 +326,8 @@ H5RS_dup(H5RS_str_t *ret_value)
H5RS_str_t *
H5RS_dup_str(const char *s)
{
- char *new_str; /* Duplicate of string */
- size_t path_len; /* Length of the path */
+ char * new_str; /* Duplicate of string */
+ size_t path_len; /* Length of the path */
H5RS_str_t *ret_value;
FUNC_ENTER_NOAPI(NULL)
@@ -348,7 +339,7 @@ H5RS_dup_str(const char *s)
path_len = HDstrlen(s);
/* Allocate space for the string */
- if(NULL == (new_str = (char *)H5FL_BLK_MALLOC(str_buf, path_len + 1)))
+ if (NULL == (new_str = (char *)H5FL_BLK_MALLOC(str_buf, path_len + 1)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Copy name for full path */
@@ -361,7 +352,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5RS_dup_str() */
-
/*--------------------------------------------------------------------------
NAME
H5RS_cmp
@@ -398,7 +388,6 @@ H5RS_cmp(const H5RS_str_t *rs1, const H5RS_str_t *rs2)
FUNC_LEAVE_NOAPI(HDstrcmp(rs1->s, rs2->s))
} /* end H5RS_cmp() */
-
/*--------------------------------------------------------------------------
NAME
H5RS_len
@@ -429,7 +418,6 @@ H5RS_len(const H5RS_str_t *rs)
FUNC_LEAVE_NOAPI((ssize_t)HDstrlen(rs->s))
} /* end H5RS_len() */
-
/*--------------------------------------------------------------------------
NAME
H5RS_get_str
@@ -463,7 +451,6 @@ H5RS_get_str(const H5RS_str_t *rs)
FUNC_LEAVE_NOAPI(rs->s)
} /* end H5RS_get_str() */
-
/*--------------------------------------------------------------------------
NAME
H5RS_get_count
@@ -494,4 +481,3 @@ H5RS_get_count(const H5RS_str_t *rs)
FUNC_LEAVE_NOAPI(rs->n)
} /* end H5RS_get_count() */
-