summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/strfd.c
diff options
context:
space:
mode:
authorGluster Ant <bugzilla-bot@gluster.org>2018-09-12 17:52:45 +0530
committerNigel Babu <nigelb@redhat.com>2018-09-12 17:52:45 +0530
commite16868dede6455cab644805af6fe1ac312775e13 (patch)
tree15aebdb4fff2d87cf8a72f836816b3aa634da58d /libglusterfs/src/strfd.c
parent45a71c0548b6fd2c757aa2e7b7671a1411948894 (diff)
Land part 2 of clang-format changes
Change-Id: Ia84cc24c8924e6d22d02ac15f611c10e26db99b4 Signed-off-by: Nigel Babu <nigelb@redhat.com>
Diffstat (limited to 'libglusterfs/src/strfd.c')
-rw-r--r--libglusterfs/src/strfd.c101
1 files changed, 51 insertions, 50 deletions
diff --git a/libglusterfs/src/strfd.c b/libglusterfs/src/strfd.c
index 002d48629bc..ad66b622361 100644
--- a/libglusterfs/src/strfd.c
+++ b/libglusterfs/src/strfd.c
@@ -16,77 +16,78 @@
#include "common-utils.h"
strfd_t *
-strfd_open ()
+strfd_open()
{
- strfd_t *strfd = NULL;
+ strfd_t *strfd = NULL;
- strfd = GF_CALLOC(1, sizeof(*strfd), gf_common_mt_strfd_t);
+ strfd = GF_CALLOC(1, sizeof(*strfd), gf_common_mt_strfd_t);
- return strfd;
+ return strfd;
}
int
-strvprintf (strfd_t *strfd, const char *fmt, va_list ap)
+strvprintf(strfd_t *strfd, const char *fmt, va_list ap)
{
- char *str = NULL;
- int size = 0;
-
- size = vasprintf (&str, fmt, ap);
-
- if (size < 0)
- return size;
-
- if (!strfd->alloc_size) {
- strfd->data = GF_CALLOC (max(size + 1, 4096), 1,
- gf_common_mt_strfd_data_t);
- if (!strfd->data) {
- free (str); /* NOT GF_FREE */
- return -1;
- }
- strfd->alloc_size = max(size + 1, 4096);
- }
+ char *str = NULL;
+ int size = 0;
+
+ size = vasprintf(&str, fmt, ap);
+
+ if (size < 0)
+ return size;
- if (strfd->alloc_size <= (strfd->size + size)) {
- char *tmp_ptr = NULL;
- int new_size = max ((strfd->alloc_size * 2),
- gf_roundup_next_power_of_two (strfd->size + size + 1));
- tmp_ptr = GF_REALLOC (strfd->data, new_size);
- if (!tmp_ptr) {
- free (str); /* NOT GF_FREE */
- return -1;
- }
- strfd->alloc_size = new_size;
- strfd->data = tmp_ptr;
+ if (!strfd->alloc_size) {
+ strfd->data = GF_CALLOC(max(size + 1, 4096), 1,
+ gf_common_mt_strfd_data_t);
+ if (!strfd->data) {
+ free(str); /* NOT GF_FREE */
+ return -1;
+ }
+ strfd->alloc_size = max(size + 1, 4096);
+ }
+
+ if (strfd->alloc_size <= (strfd->size + size)) {
+ char *tmp_ptr = NULL;
+ int new_size = max(
+ (strfd->alloc_size * 2),
+ gf_roundup_next_power_of_two(strfd->size + size + 1));
+ tmp_ptr = GF_REALLOC(strfd->data, new_size);
+ if (!tmp_ptr) {
+ free(str); /* NOT GF_FREE */
+ return -1;
}
+ strfd->alloc_size = new_size;
+ strfd->data = tmp_ptr;
+ }
- /* Copy the trailing '\0', but do not account for it in ->size.
- This allows safe use of strfd->data as a string. */
- memcpy (strfd->data + strfd->size, str, size + 1);
- strfd->size += size;
+ /* Copy the trailing '\0', but do not account for it in ->size.
+ This allows safe use of strfd->data as a string. */
+ memcpy(strfd->data + strfd->size, str, size + 1);
+ strfd->size += size;
- free (str); /* NOT GF_FREE */
+ free(str); /* NOT GF_FREE */
- return size;
+ return size;
}
int
-strprintf (strfd_t *strfd, const char *fmt, ...)
+strprintf(strfd_t *strfd, const char *fmt, ...)
{
- int ret = 0;
- va_list ap;
+ int ret = 0;
+ va_list ap;
- va_start (ap, fmt);
- ret = strvprintf (strfd, fmt, ap);
- va_end (ap);
+ va_start(ap, fmt);
+ ret = strvprintf(strfd, fmt, ap);
+ va_end(ap);
- return ret;
+ return ret;
}
int
-strfd_close (strfd_t *strfd)
+strfd_close(strfd_t *strfd)
{
- GF_FREE (strfd->data);
- GF_FREE (strfd);
+ GF_FREE(strfd->data);
+ GF_FREE(strfd);
- return 0;
+ return 0;
}