Remove tal_len, use tal_count() or tal_bytelen().

tal_count() is used where there's a type, even if it's char or u8, and
tal_bytelen() is going to replace tal_len() for clarity: it's only needed
where a pointer is void.

We shim tal_bytelen() for now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2018-07-28 15:30:16 +09:30
committed by Christian Decker
parent eae9b81099
commit 5cf34d6618
57 changed files with 200 additions and 195 deletions

View File

@@ -17,7 +17,7 @@ static const u32 global_features[] = {
*/
static void set_bit(u8 **ptr, u32 bit)
{
size_t len = tal_len(*ptr);
size_t len = tal_count(*ptr);
if (bit / 8 >= len) {
size_t newlen = (bit / 8) + 1;
u8 *newarr = tal_arrz(tal_parent(*ptr), u8, newlen);
@@ -31,8 +31,8 @@ static void set_bit(u8 **ptr, u32 bit)
static bool test_bit(const u8 *features, size_t byte, unsigned int bit)
{
assert(byte < tal_len(features));
return features[tal_len(features) - 1 - byte] & (1 << (bit % 8));
assert(byte < tal_count(features));
return features[tal_count(features) - 1 - byte] & (1 << (bit % 8));
}
/* We don't insist on anything, it's all optional. */
@@ -59,7 +59,7 @@ static bool feature_set(const u8 *features, size_t bit)
{
size_t bytenum = bit / 8;
if (bytenum >= tal_len(features))
if (bytenum >= tal_count(features))
return false;
return test_bit(features, bytenum, bit % 8);