[PATCH 3/5] Add bitvector functions from osmo-pcu

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.

Holger Freyther holger at freyther.de
Fri Jan 22 21:48:30 UTC 2016


> On 22 Jan 2016, at 16:46, suraev at alumni.ntnu.no wrote:
> 
> 

> @@ -74,5 +75,12 @@ int bitvec_find_bit_pos(const struct bitvec *bv, unsigned int n, enum bit_value
> int bitvec_spare_padding(struct bitvec *bv, unsigned int up_to_bit);
> int bitvec_get_bytes(struct bitvec *bv, uint8_t *bytes, unsigned int count);
> int bitvec_set_bytes(struct bitvec *bv, const uint8_t *bytes, unsigned int count);
> +struct bitvec * bitvec_alloc(unsigned int size);

coding style to have ' * ' in the middle of nowwhere




> #define BITNUM_FROM_COMP(byte, bit)	((byte*8)+bit)
> 
> +void *bv_tall_ctx;

static? how is the talloc context "rooted" so that it will show up in
the leak detection?


> +struct bitvec *bitvec_alloc(unsigned size)
> +{
> +	struct bitvec *bv = talloc_zero(bv_tall_ctx, struct bitvec);
> +	bv->data_len = size;
> +	bv->cur_bit = 0;
> +	bv->data = talloc_zero_array(bv_tall_ctx, uint8_t, size);
> +	return bv;

bv is a talloc context itself so it should be used to create data instead
of the global one.



> +unsigned int bitvec_pack(struct bitvec *bv, uint8_t *buffer)
> +{
> +	unsigned int i = 0;
> +	for (i = 0; i < bv->data_len; i++)
> +	{

coding style for the '{' and in other methods too.






More information about the OpenBSC mailing list