| 499 | } |
| 500 | |
| 501 | u8 *featurebits_or(const tal_t *ctx, const u8 *f1 TAKES, const u8 *f2 TAKES) |
| 502 | { |
| 503 | size_t l1 = tal_bytelen(f1), l2 = tal_bytelen(f2); |
| 504 | u8 *result; |
| 505 | |
| 506 | /* Easier if f2 is shorter. */ |
| 507 | if (l1 < l2) |
| 508 | return featurebits_or(ctx, f2, f1); |
| 509 | |
| 510 | assert(l2 <= l1); |
| 511 | result = tal_dup_arr(ctx, u8, f1, l1, 0); |
| 512 | |
| 513 | /* Note: features are packed to the end of the bitmap */ |
| 514 | for (size_t i = 0; i < l2; i++) |
| 515 | result[l1 - l2 + i] |= f2[i]; |
| 516 | |
| 517 | /* Cleanup the featurebits if we were told to do so. */ |
| 518 | if (taken(f2)) |
| 519 | tal_free(f2); |
| 520 | |
| 521 | return result; |
| 522 | } |
| 523 | |
| 524 | void featurebits_unset(u8 **ptr, size_t bit) |
| 525 | { |