BitVecInitWithCapacityAlloc
Description
Initialize bitvector with initial capacity and explicit allocator. Creates a bitvector with reserved space for the specified number of bits.
Parameters
| Name | Direction | Description |
|---|---|---|
cap |
in | Initial capacity in bits. |
alloc |
in | Allocator to bind to the bitvector. |
Usage example (from documentation)
BitVec flags = BitVecInitWithCapacityAlloc(64, allocator);Success
Returns an initialized BitVec. Length is 0, capacity is at least cap bits, the byte buffer has been allocated and zero-filled, and alloc has been bound into the bitvector’s allocator slot.
Failure
Returns an empty bitvector (length 0, capacity 0, data NULL) when allocation of the underlying byte buffer fails. The allocator is still bound so the returned object is safe to BitVecDeinit or retry-reserve.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Int.c:41:
}
*out = int_wrap(BitVecInitWithCapacityAlloc(capacity, alloc));
if (capacity != 0 && out->bits.capacity < capacity) {
IntDeinit(out);- In
BitVec.c:38:
#define BYTES_FOR_BITS(bits) (((bits) + BITS_PER_BYTE - 1) / BITS_PER_BYTE)
BitVec BitVecInitWithCapacityAlloc(u64 cap, Allocator alloc) {
BitVec result = BitVecInit(alloc);- In
Init.h:165:
#define BitVecInitWithCapacity(...) \
CONCAT(BitVecInitWithCapacity_, BITVEC_INIT_WITH_CAPACITY_HAS_ARGS(__VA_ARGS__))(__VA_ARGS__)
#define BitVecInitWithCapacity_1(cap) BitVecInitWithCapacityAlloc((cap), DefaultAllocator())
#define BitVecInitWithCapacity_2(cap, alloc) BitVecInitWithCapacityAlloc((cap), (alloc))- In
Init.h:166:
CONCAT(BitVecInitWithCapacity_, BITVEC_INIT_WITH_CAPACITY_HAS_ARGS(__VA_ARGS__))(__VA_ARGS__)
#define BitVecInitWithCapacity_1(cap) BitVecInitWithCapacityAlloc((cap), DefaultAllocator())
#define BitVecInitWithCapacity_2(cap, alloc) BitVecInitWithCapacityAlloc((cap), (alloc))
Last updated on