]> git.ozlabs.org Git - ccan/commitdiff
tal: rename tal_len to tal_bytelen.
authorRusty Russell <rusty@rustcorp.com.au>
Fri, 27 Jul 2018 04:20:42 +0000 (13:50 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Fri, 27 Jul 2018 04:20:42 +0000 (13:50 +0930)
I had a bug caused by using tal_len instead of tal_count: let's make
it explicit. @jb55 commented "ha. I always forget which one does which... Ack"

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

index 0e3c97b390003dfbae3ad82687ce3f35c5d52ce0..7018d9fc98b3d80f33fcdaab0f4ad0ea2609fbf7 100644 (file)
@@ -656,7 +656,7 @@ const char *tal_name(const tal_t *t)
        return n->name;
 }
 
-size_t tal_len(const tal_t *ptr)
+size_t tal_bytelen(const tal_t *ptr)
 {
        struct length *l;
 
index 30c8e7bb9207c4daba3cb046e651ff288de21bfe..71f7698601c1f933b62670ae83769d6c47de5cd9 100644 (file)
@@ -310,16 +310,16 @@ const char *tal_name(const tal_t *ptr);
  * Returns 0 if @ptr has no length property or is NULL, but be aware
  * that that is also a valid size!
  */
-#define tal_count(p) (tal_len(p) / sizeof(*p))
+#define tal_count(p) (tal_bytelen(p) / sizeof(*p))
 
 /**
- * tal_len - get the count of bytes in a tal_arr.
+ * tal_bytelen - get the count of bytes in a tal_arr.
  * @ptr: The tal allocated object array (or NULL)
  *
  * Returns 0 if @ptr has no length property or NULL, but be aware that that is
  * also a valid size!
  */
-size_t tal_len(const tal_t *ptr);
+size_t tal_bytelen(const tal_t *ptr);
 
 /**
  * tal_first - get the first immediate tal object child.
index 33049b9f78d3e2edc9e675ed2afc7450d9b9597d..54ba8c19ffe7ae486d096e4856f1dfa41dc91700 100644 (file)
@@ -46,7 +46,7 @@ int main(void)
        plan_tests(2 + 19 * 3);
 
        p1 = NULL;
-       ok1(tal_len(p1) == 0);
+       ok1(tal_bytelen(p1) == 0);
        ok1(tal_count(p1) == 0);
 
        for (i = 0; i < 3; i++) {