Skip to content
BitVecInitWithCapacity

BitVecInitWithCapacity

Description

Initialize an empty BitVec and reserve room for at least cap bits. Public callers reach this through the BitVecInitWithCapacity overload set.

Parameters

Name Direction Description
cap in Minimum bit capacity to reserve up front.
alloc in Allocator that owns the backing buffer.

Success

Returns a live, empty BitVec whose capacity is at least cap bits.

Failure

Returns an empty BitVec with NULL data and zero capacity on allocator OOM; the caller must check before use.

Usage example (Cross-references)

Usage examples (Cross-references)
        }
    
        *out = int_wrap(BitVecInitWithCapacity(capacity, alloc));
        if (capacity != 0 && BitVecCapacity(INT_BITS(out)) < capacity) {
            IntDeinit(out);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        BitVec bv = BitVecInitWithCapacity(64, ALLOCATOR_OF(&alloc));
    
        bool result = (BitVecCapacity(&bv) == 64);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        BitVec bv = BitVecInitWithCapacity(64, ALLOCATOR_OF(&alloc));
    
        bool result = (BitVecByteSize(&bv) == 8);
Last updated on