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

Function featurebits_or

common/features.c:516–536  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

514}
515
516u8 *featurebits_or(const tal_t *ctx, const u8 *f1 TAKES, const u8 *f2 TAKES)
517{
518 size_t l1 = tal_bytelen(f1), l2 = tal_bytelen(f2);
519 u8 *result;
520
521 /* Easier if f2 is shorter. */
522 if (l1 < l2)
523 return featurebits_or(ctx, f2, f1);
524
525 assert(l2 <= l1);
526 result = tal_dup_arr(ctx, u8, f1, l1, 0);
527
528 /* Note: features are packed to the end of the bitmap */
529 for (size_t i = 0; i < l2; i++)
530 result[l1 - l2 + i] |= f2[i];
531
532 /* Cleanup the featurebits if we were told to do so. */
533 tal_free_if_taken(f2);
534
535 return result;
536}
537
538void featurebits_unset(u8 **ptr, size_t bit)
539{

Callers 3

peer_init_receivedFunction · 0.85
json_getinfoFunction · 0.85
test_featurebits_orFunction · 0.85

Calls 2

tal_bytelenFunction · 0.85
tal_free_if_takenFunction · 0.85

Tested by 1

test_featurebits_orFunction · 0.68