diff common/strhelp.c @ 905:698b6a9bd75e

Fix coding style for C code astyle --style=gnu --indent=spaces=2
author Andre Heinecke <andre.heinecke@intevation.de>
date Wed, 13 Aug 2014 15:49:47 +0200
parents 17e1c8f37d72
children ffdc8cba139a
line wrap: on
line diff
--- a/common/strhelp.c	Wed Aug 13 15:44:35 2014 +0200
+++ b/common/strhelp.c	Wed Aug 13 15:49:47 2014 +0200
@@ -36,85 +36,89 @@
 static void
 out_of_core(void)
 {
-    fputs("\nfatal: out of memory\n", stderr);
-    exit(2);
+  fputs("\nfatal: out of memory\n", stderr);
+  exit(2);
 }
 void *
 xmalloc( size_t n )
 {
-    void *p = malloc( n );
-    if( !p )
-        out_of_core();
-    return p;
+  void *p = malloc( n );
+  if( !p )
+    out_of_core();
+  return p;
 }
 
 void *
 xrealloc( void *a, size_t n )
 {
-    void *p = realloc( a, n );
-    if( !p )
-        out_of_core();
-    return p;
+  void *p = realloc( a, n );
+  if( !p )
+    out_of_core();
+  return p;
 }
 
 char *
 xstrndup( const char *string, const size_t len )
 {
-    char *p = xmalloc( len + 1 );
-    memcpy( p, string, len );
-    p[len] = '\0';
-    return p;
+  char *p = xmalloc( len + 1 );
+  memcpy( p, string, len );
+  p[len] = '\0';
+  return p;
 }
 
 unsigned int
 strv_length (char **str_array)
 {
-    unsigned int i = 0;
+  unsigned int i = 0;
 
-    if (!str_array)
-        return 0;
+  if (!str_array)
+    return 0;
 
-    while (str_array[i])
-        ++i;
+  while (str_array[i])
+    ++i;
 
-    return i;
+  return i;
 }
 
 void strv_append (char ***pArray, const char *string, const size_t len)
 {
-    unsigned int old_len = 0;
+  unsigned int old_len = 0;
 
-    if (!*pArray) {
-        *pArray = xmalloc(2 * sizeof(char*));
-        (*pArray)[0] = xstrndup(string, len);
-        (*pArray)[1] = NULL;
-        return;
+  if (!*pArray)
+    {
+      *pArray = xmalloc(2 * sizeof(char*));
+      (*pArray)[0] = xstrndup(string, len);
+      (*pArray)[1] = NULL;
+      return;
     }
-    old_len = strv_length(*pArray);
-    *pArray = xrealloc(*pArray, sizeof(char**) * (old_len + 2));
+  old_len = strv_length(*pArray);
+  *pArray = xrealloc(*pArray, sizeof(char**) * (old_len + 2));
 
-    (*pArray)[old_len] = xstrndup(string, len);
-    (*pArray)[old_len + 1] = NULL;
+  (*pArray)[old_len] = xstrndup(string, len);
+  (*pArray)[old_len + 1] = NULL;
 }
 
 void
 str_append_str(char **pDst, size_t *dst_len, const char *appendage, const size_t len)
 {
-    if (!appendage)
-        return;
+  if (!appendage)
+    return;
 
-    if (!(*pDst)) {
-        *pDst = xstrndup(appendage, len);
-        *dst_len = len;
-    } else {
-        size_t new_size = (*dst_len) + len + 1;
-        char *p_old = *pDst;
-        *pDst = xmalloc(new_size);
-        strncpy(*pDst, p_old, *dst_len);
-        strncpy(*pDst + *dst_len, appendage, len);
-        *dst_len = new_size - 1;
-        (*pDst)[*dst_len] = '\0';
-        free (p_old);
+  if (!(*pDst))
+    {
+      *pDst = xstrndup(appendage, len);
+      *dst_len = len;
+    }
+  else
+    {
+      size_t new_size = (*dst_len) + len + 1;
+      char *p_old = *pDst;
+      *pDst = xmalloc(new_size);
+      strncpy(*pDst, p_old, *dst_len);
+      strncpy(*pDst + *dst_len, appendage, len);
+      *dst_len = new_size - 1;
+      (*pDst)[*dst_len] = '\0';
+      free (p_old);
     }
 }
 
@@ -171,31 +175,34 @@
 int str_base64_decode(char **dst, size_t *dst_size, char *src,
                       size_t src_size)
 {
-    int ret = -1;
+  int ret = -1;
 
-    if (!dst || *dst) {
-        return -1;
+  if (!dst || *dst)
+    {
+      return -1;
     }
 
-    /* Check the needed size for the buffer */
-    ret = base64_decode(NULL, dst_size,
-                        (unsigned char *)src, src_size);
+  /* Check the needed size for the buffer */
+  ret = base64_decode(NULL, dst_size,
+                      (unsigned char *)src, src_size);
 
-    if (ret != 0 && ret != POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL) {
-        return ret;
+  if (ret != 0 && ret != POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL)
+    {
+      return ret;
     }
 
-    *dst = xmalloc(*dst_size);
-    memset (*dst, 0, *dst_size);
+  *dst = xmalloc(*dst_size);
+  memset (*dst, 0, *dst_size);
 
-    ret = base64_decode((unsigned char *)*dst, dst_size,
-                        (unsigned char *)src, src_size);
-    if (ret) {
-        free (*dst);
-        *dst = NULL;
-        *dst_size = 0;
+  ret = base64_decode((unsigned char *)*dst, dst_size,
+                      (unsigned char *)src, src_size);
+  if (ret)
+    {
+      free (*dst);
+      *dst = NULL;
+      *dst_size = 0;
     }
-    return ret;
+  return ret;
 }
 
 void

http://wald.intevation.org/projects/trustbridge/