[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-exchange] branch master updated: url joining: grow s
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-exchange] branch master updated: url joining: grow strings correctly |
Date: |
Wed, 31 Jan 2018 18:37:48 +0100 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository exchange.
The following commit(s) were added to refs/heads/master by this push:
new 111f8f2 url joining: grow strings correctly
111f8f2 is described below
commit 111f8f2381ef40485c3007823911f2da63d69139
Author: Florian Dold <address@hidden>
AuthorDate: Wed Jan 31 18:37:40 2018 +0100
url joining: grow strings correctly
---
src/util/util.c | 50 +++++++++++++++++++++++++-------------------------
1 file changed, 25 insertions(+), 25 deletions(-)
diff --git a/src/util/util.c b/src/util/util.c
index c31dc1e..ceb3a3a 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -229,20 +229,20 @@ TALER_urlencode (const char *s)
* Grow a string in a buffer with the given size.
* The buffer is re-allocated if necessary.
*
- * @param s string buffer
+ * @param s pointer to string buffer
* @param p the string to append
* @param n pointer to the allocated size of n
* @returns pointer to the resulting buffer,
* might differ from @a s (!!)
*/
static char *
-grow_string (char *s, const char *p, size_t *n)
+grow_string (char **s, const char *p, size_t *n)
{
- for (; strlen (s) + strlen (p) >= *n; *n *= 2);
- s = GNUNET_realloc (s, *n);
+ for (; strlen (*s) + strlen (p) >= *n; *n *= 2);
+ *s = GNUNET_realloc (*s, *n);
GNUNET_assert (NULL != s);
- strncat (s, p, *n);
- return s;
+ strncat (*s, p, *n);
+ return *s;
}
@@ -252,16 +252,16 @@ grow_string (char *s, const char *p, size_t *n)
*
* Ensures that slashes are removed or added when joining paths.
*
- * @param s string buffer
+ * @param s pointer to string buffer
* @param p the string to append
* @param n pointer to the allocated size of n
* @returns pointer to the resulting buffer,
* might differ from @a s (!!)
*/
static char *
-grow_string_path (char *s, const char *p, size_t *n)
+grow_string_path (char **s, const char *p, size_t *n)
{
- char a = (0 == strlen (s)) ? '\0' : s[strlen (s) - 1];
+ char a = (0 == strlen (*s)) ? '\0' : (*s)[strlen (*s) - 1];
char b = (0 == strlen (p)) ? '\0' : p[0];
if ( (a == '/') && (b == '/'))
@@ -270,7 +270,7 @@ grow_string_path (char *s, const char *p, size_t *n)
}
else if ( (a != '/') && (b != '/'))
{
- if (NULL == (s = grow_string (s, "/", n)))
+ if (NULL == (*s = grow_string (s, "/", n)))
return NULL;
}
return grow_string (s, p, n);
@@ -299,9 +299,9 @@ TALER_url_join (const char *base_url,
GNUNET_assert (NULL != res);
- grow_string (res, base_url, &n);
+ grow_string (&res, base_url, &n);
- grow_string_path (res, path, &n);
+ grow_string_path (&res, path, &n);
va_start (args, path);
@@ -314,12 +314,12 @@ TALER_url_join (const char *base_url,
value = va_arg (args, char *);
if (NULL == value)
continue;
- grow_string (res, (0 == iparam) ? "?" : "&", &n);
+ grow_string (&res, (0 == iparam) ? "?" : "&", &n);
iparam++;
- grow_string (res, key, &n);
- grow_string (res, "=", &n);
+ grow_string (&res, key, &n);
+ grow_string (&res, "=", &n);
enc = TALER_urlencode (value);
- grow_string (res, enc, &n);
+ grow_string (&res, enc, &n);
GNUNET_free (enc);
}
@@ -352,13 +352,13 @@ url_absolute_raw_va (const char *proto,
char *enc;
unsigned int iparam = 0;
- grow_string (res, proto, &n);
- grow_string (res, "://", &n);
- grow_string (res, host, &n);
+ grow_string (&res, proto, &n);
+ grow_string (&res, "://", &n);
+ grow_string (&res, host, &n);
- grow_string_path (res, prefix, &n);
+ grow_string_path (&res, prefix, &n);
- grow_string_path (res, path, &n);
+ grow_string_path (&res, path, &n);
while (1) {
char *key;
@@ -369,12 +369,12 @@ url_absolute_raw_va (const char *proto,
value = va_arg (args, char *);
if (NULL == value)
continue;
- grow_string (res, (0 == iparam) ? "?" : "&", &n);
+ grow_string (&res, (0 == iparam) ? "?" : "&", &n);
iparam++;
- grow_string (res, key, &n);
- grow_string (res, "=", &n);
+ grow_string (&res, key, &n);
+ grow_string (&res, "=", &n);
enc = TALER_urlencode (value);
- grow_string (res, enc, &n);
+ grow_string (&res, enc, &n);
GNUNET_free (enc);
}
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [taler-exchange] branch master updated: url joining: grow strings correctly,
gnunet <=