MCPcopy Create free account
hub / github.com/ElementsProject/lightning / featurebits_or

Function featurebits_or

common/features.c:501–522  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

499}
500
501u8 *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
524void featurebits_unset(u8 **ptr, size_t bit)
525{

Callers 2

peer_init_receivedFunction · 0.50
test_featurebits_orFunction · 0.50

Calls 3

tal_bytelenFunction · 0.85
takenFunction · 0.85
tal_freeFunction · 0.85

Tested by 1

test_featurebits_orFunction · 0.40