Skip to content

Commit

Permalink
tools/generate-wire.py: fix loop logic for towire_xxx_array
Browse files Browse the repository at this point in the history
We have to handle singletons which are arrays of variable-length entries:
this needs to be a ptr-to-ptr.

```C
struct blinded_payinfo {
        u32 fee_base_msat;
        u32 fee_proportional_millionths;
        u16 cltv_expiry_delta;
        u8 *features;
};
```

Before:
```C
struct tlv_invoice_tlvs {
...
	struct blinded_payinfo *blindedpay;
```

After:
```C
struct tlv_invoice_tlvs {
...
	struct blinded_payinfo **blindedpay;
```

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Sep 2, 2020
1 parent 897c53c commit aa441e3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tools/gen/header_template
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ struct ${tlv.struct_name()} {
* tlv_field entries above to save on memory. */
% for msg in tlv.messages.values():
% if msg.singleton():
## Array of variable-length elems needs ptr-to-ptr!
% if msg.singleton().is_varlen() and msg.singleton().type_obj.is_varsize():
${msg.singleton().type_obj.type_name()} **${msg.name};
% else:
${msg.singleton().type_obj.type_name()} *${msg.name};
% endif
% else:
struct ${msg.struct_name()} *${msg.name};
% endif
Expand Down

0 comments on commit aa441e3

Please sign in to comment.