Skip to content
BitVecTryFromStr

BitVecTryFromStr

Description

Parse a bitvector from a null-terminated string using an explicit allocator.

Parameters

Name Direction Description
out out Destination bitvector.
str in Input string containing 0 and 1 characters.
alloc in Allocator to bind to the destination bitvector.

Success

Returns true and initializes out.

Failure

Returns false on invalid input or allocation failure.

Usage example (Cross-references)

Usage examples (Cross-references)
        Zstr   str = "1011";
        BitVec bv;
        bool   ok = BitVecTryFromStr(&bv, str, ALLOCATOR_OF(&alloc));
    
        // Check result
        BitVec bv;
        Str    str;
        bool   ok     = BitVecTryFromStr(&bv, "101001", ALLOCATOR_OF(&alloc));
        bool   result = ok && (BitVecAllocator(&bv)->effort == alloc.base.effort) &&
                      (BitVecAllocator(&bv)->retry_limit == alloc.base.retry_limit);
Last updated on