aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2016-07-13 12:16:46 +0200
committerHolger Freyther <holger@freyther.de>2016-07-13 16:26:32 +0000
commit5d94b5455f50f9e1d35a706ad5956332922f06d5 (patch)
tree2419c3ffecd75f57b02f21e589dd705bf4eb6895
parent1a679127af3311efb84cf435005c8711beda7c25 (diff)
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
-rw-r--r--src/bitvector.cpp17
-rw-r--r--src/bitvector.h8
2 files changed, 7 insertions, 18 deletions
diff --git a/src/bitvector.cpp b/src/bitvector.cpp
index 10284073..dcb3baf5 100644
--- a/src/bitvector.cpp
+++ b/src/bitvector.cpp
@@ -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)
{
diff --git a/src/bitvector.h b/src/bitvector.h
index b14d2040..246824d5 100644
--- a/src/bitvector.h
+++ b/src/bitvector.h
@@ -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