bitvector: Remove code clone and fallback to C implementation

This routine has been moved from from here to libosmocore and as
part of the C++ -> C the reference got converted to a pointer. We
have a lot of code that calls the method with the reference and
instead of updating the callers, create a short inline wrapper to
call the C routine.

Change-Id: Idd16ce251a42bad4401c2bf3a8fa6af70fb600ff
This commit is contained in:
Holger Hans Peter Freyther 2016-07-13 12:16:46 +02:00 committed by Holger Freyther
parent 1a679127af
commit 5d94b5455f
2 changed files with 7 additions and 18 deletions

View File

@ -101,23 +101,6 @@ uint64_t bitvec_read_field(struct bitvec *bv, unsigned& read_index, unsigned len
}
int bitvec_write_field(struct bitvec *bv, unsigned& write_index, uint64_t val, unsigned len)
{
unsigned int i;
int rc;
bv->cur_bit = write_index;
for (i = 0; i < len; i++) {
int bit = 0;
if (val & ((uint64_t)1 << (len - i - 1)))
bit = 1;
rc = bitvec_set_bit(bv, (bit_value)bit);
if (rc)
return rc;
}
write_index += len;
return 0;
}
int bitvec_write_field_lh(struct bitvec *bv, unsigned& write_index,
uint64_t val, unsigned len)
{

View File

@ -38,9 +38,15 @@ int bitvec_unhex(struct bitvec *bv, const char* src);
unsigned int bitvec_pack(struct bitvec *bv, uint8_t *buffer);
unsigned int bitvec_unpack(struct bitvec *bv, uint8_t *buffer);
uint64_t bitvec_read_field(struct bitvec *bv, unsigned& read_index, unsigned len);
int bitvec_write_field(struct bitvec *bv, unsigned& write_index, uint64_t val, unsigned len);
int bitvec_write_field_lh(struct bitvec *bv, unsigned& write_index, uint64_t val, unsigned len);
static inline int bitvec_write_field(struct bitvec *bv, unsigned& write_index, uint64_t val, unsigned len)
{
/* Call the libosmocore variant */
return ::bitvec_write_field(bv, &write_index, val, len);
}
/*! }@ */
#endif // BITVECTOR_H