Skip to content
BitVecTryFromStrAlloc

BitVecTryFromStrAlloc

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)
    }
    
    bool BitVecTryFromStrAlloc(BitVec *out, const char *str, Allocator alloc) {
        if (!str) {
            LOG_FATAL("str is NULL");
        BitVec result;
    
        if (!BitVecTryFromStrAlloc(&result, str, alloc)) {
            result = BitVecInit(alloc);
        }
    #define BITVEC_TRY_FROM_STR_HAS_ARGS(...)                         BITVEC_TRY_FROM_STR_HAS_ARGS_IMPL(__VA_ARGS__, 3, 2, 1, 0)
    #define BitVecTryFromStr(...)                                     CONCAT(BitVecTryFromStr_, BITVEC_TRY_FROM_STR_HAS_ARGS(__VA_ARGS__))(__VA_ARGS__)
    #define BitVecTryFromStr_2(out, str)                              BitVecTryFromStrAlloc((out), (str), DefaultAllocator())
    #define BitVecTryFromStr_3(out, str, alloc)                       BitVecTryFromStrAlloc((out), (str), (alloc))
    #define BitVecTryFromStr(...)                                     CONCAT(BitVecTryFromStr_, BITVEC_TRY_FROM_STR_HAS_ARGS(__VA_ARGS__))(__VA_ARGS__)
    #define BitVecTryFromStr_2(out, str)                              BitVecTryFromStrAlloc((out), (str), DefaultAllocator())
    #define BitVecTryFromStr_3(out, str, alloc)                       BitVecTryFromStrAlloc((out), (str), (alloc))
    
    ///
Last updated on