> On 25 Jan 2016, at 13:28, Max (☭) <[email protected]> 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

Reply via email to