mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-19 05:44:12 +01:00
ccan: update to get tal_len(NULL)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
8159c4458a
commit
ad82d29379
@ -1,3 +1,3 @@
|
||||
CCAN imported from http://ccodearchive.net.
|
||||
|
||||
CCAN version: init-2344-g3f64234
|
||||
CCAN version: init-2354-g9b3f4ef
|
||||
|
@ -654,6 +654,9 @@ size_t tal_len(const tal_t *ptr)
|
||||
{
|
||||
struct length *l;
|
||||
|
||||
if (!ptr)
|
||||
return 0;
|
||||
|
||||
l = find_property(debug_tal(to_tal_hdr(ptr)), LENGTH);
|
||||
if (!l)
|
||||
return 0;
|
||||
|
@ -304,18 +304,18 @@ const char *tal_name(const tal_t *ptr);
|
||||
|
||||
/**
|
||||
* tal_count - get the count of objects in a tal_arr.
|
||||
* @ptr: The tal allocated object array.
|
||||
* @ptr: The tal allocated object array (or NULL)
|
||||
*
|
||||
* Returns 0 if @ptr has no length property, but be aware that that is
|
||||
* also a valid size!
|
||||
* 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))
|
||||
|
||||
/**
|
||||
* tal_len - get the count of bytes in a tal_arr.
|
||||
* @ptr: The tal allocated object array.
|
||||
* @ptr: The tal allocated object array (or NULL)
|
||||
*
|
||||
* Returns 0 if @ptr has no length property, but be aware that that is
|
||||
* 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);
|
||||
|
@ -43,7 +43,11 @@ int main(void)
|
||||
|
||||
tal_set_backend(my_alloc, my_realloc, my_free, NULL);
|
||||
|
||||
plan_tests(19 * 3);
|
||||
plan_tests(2 + 19 * 3);
|
||||
|
||||
p1 = NULL;
|
||||
ok1(tal_len(p1) == 0);
|
||||
ok1(tal_count(p1) == 0);
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
move = i;
|
||||
|
Loading…
Reference in New Issue
Block a user