[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
Mon Jan 25 15:23:57 UTC 2016


> On 25 Jan 2016, at 13:28, Max (☭) <suraev at alumni.ntnu.no> wrote:
> 
> <0001-Add-bitvec-related-functions-from-Osmo-PCU.patch>


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

talloc has hierachies. So we pass the context into it but bv->data should
be a child of "data". As a library function it needs to handle OOM as well.


	bv = talloc_zero(bvctx, struct bitvec);
	if (!bv)
		return NULL;
	bv->data_len = size;
	..
	bv->data = talloc_zero_array(bv, uint8_t, size);
	if (!bv->data) {
		talloc_free(bv);
		return NULL;
	}
	return bv


holger


More information about the OpenBSC mailing list