]> git.ozlabs.org Git - ccan/commitdiff
tal/str: rename tal_asprintf/tal_vasprintf to tal_fmt/tal_vfmt.
authorRusty Russell <rusty@rustcorp.com.au>
Mon, 3 Dec 2012 08:59:39 +0000 (19:29 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Mon, 3 Dec 2012 08:59:39 +0000 (19:29 +1030)
Shorter, sweeter, and less legacy.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ccan/tal/str/str.c
ccan/tal/str/str.h
ccan/tal/str/test/run-string.c
ccan/tal/str/test/run-take.c

index 4606b47e3356955f7989389b9729db33c5b3b71f..771c07c24ee69ddd2bac49c408f62766768f4c67 100644 (file)
@@ -40,19 +40,19 @@ char *tal_strndup(const tal_t *ctx, const char *p, size_t n)
        return ret;
 }
 
        return ret;
 }
 
-char *tal_asprintf(const tal_t *ctx, const char *fmt, ...)
+char *tal_fmt(const tal_t *ctx, const char *fmt, ...)
 {
        va_list ap;
        char *ret;
 
        va_start(ap, fmt);
 {
        va_list ap;
        char *ret;
 
        va_start(ap, fmt);
-       ret = tal_vasprintf(ctx, fmt, ap);
+       ret = tal_vfmt(ctx, fmt, ap);
        va_end(ap);
 
        return ret;
 }
 
        va_end(ap);
 
        return ret;
 }
 
-char *tal_vasprintf(const tal_t *ctx, const char *fmt, va_list ap)
+char *tal_vfmt(const tal_t *ctx, const char *fmt, va_list ap)
 {
        size_t max;
        char *buf;
 {
        size_t max;
        char *buf;
index 4bb06b70c141ba47941a436fffe10cd53c7c6c82..4a6c474a4428a3e79998d1168b09e8c28d2f57a9 100644 (file)
@@ -24,19 +24,19 @@ char *tal_strdup(const tal_t *ctx, const char *p);
 char *tal_strndup(const tal_t *ctx, const char *p, size_t n);
 
 /**
 char *tal_strndup(const tal_t *ctx, const char *p, size_t n);
 
 /**
- * tal_asprintf - allocate a formatted string
+ * tal_fmt - allocate a formatted string
  * @ctx: NULL, or tal allocated object to be parent.
  * @fmt: the printf-style format (can be take()).
  */
  * @ctx: NULL, or tal allocated object to be parent.
  * @fmt: the printf-style format (can be take()).
  */
-char *tal_asprintf(const tal_t *ctx, const char *fmt, ...) PRINTF_FMT(2,3);
+char *tal_fmt(const tal_t *ctx, const char *fmt, ...) PRINTF_FMT(2,3);
 
 /**
 
 /**
- * tal_vasprintf - allocate a formatted string (va_list version)
+ * tal_vfmt - allocate a formatted string (va_list version)
  * @ctx: NULL, or tal allocated object to be parent.
  * @fmt: the printf-style format (can be take()).
  * @va: the va_list containing the format args.
  */
  * @ctx: NULL, or tal allocated object to be parent.
  * @fmt: the printf-style format (can be take()).
  * @va: the va_list containing the format args.
  */
-char *tal_vasprintf(const tal_t *ctx, const char *fmt, va_list ap)
+char *tal_vfmt(const tal_t *ctx, const char *fmt, va_list ap)
        PRINTF_FMT(2,0);
 
 /**
        PRINTF_FMT(2,0);
 
 /**
index 5246a8aa0513e0f44c0d1f864be9d7fdf087444d..bb614ae2fa070e09af6da909cc61b456ec2693c2 100644 (file)
@@ -36,7 +36,7 @@ int main(void)
        strcat(c, "x");
        tal_free(c);
 
        strcat(c, "x");
        tal_free(c);
 
-       c = tal_asprintf(parent, "hello %s", "there");
+       c = tal_fmt(parent, "hello %s", "there");
        ok1(strcmp(c, "hello there") == 0);
        ok1(tal_parent(c) == parent);
        tal_free(c);
        ok1(strcmp(c, "hello there") == 0);
        ok1(tal_parent(c) == parent);
        tal_free(c);
index 0cbab9e00eb41db6586876cb6088ce83dd0ded71..521e592b3820e4e49d3943b7aa05edd0cd1d6d7a 100644 (file)
@@ -27,7 +27,7 @@ int main(void)
        tal_free(c);
 
        c = tal_strdup(parent, "hello %s");
        tal_free(c);
 
        c = tal_strdup(parent, "hello %s");
-       c = tal_asprintf(parent, take(c), "there");
+       c = tal_fmt(parent, take(c), "there");
        ok1(strcmp(c, "hello there") == 0);
        ok1(tal_parent(c) == parent);
        /* No leftover allocations. */
        ok1(strcmp(c, "hello there") == 0);
        ok1(tal_parent(c) == parent);
        /* No leftover allocations. */
@@ -41,7 +41,7 @@ int main(void)
        c = NULL;
        ok1(tal_strdup(NULL, take(c)) == NULL);
        ok1(tal_strndup(NULL, take(c), 5) == NULL);
        c = NULL;
        ok1(tal_strdup(NULL, take(c)) == NULL);
        ok1(tal_strndup(NULL, take(c), 5) == NULL);
-       ok1(tal_asprintf(NULL, take(c), 0) == NULL);
+       ok1(tal_fmt(NULL, take(c), 0) == NULL);
 
        return exit_status();
 }
 
        return exit_status();
 }