Skip to content
BitVecTryToStrAlloc

BitVecTryToStrAlloc

Description

Convert a bitvector to a string using an explicit allocator.

Parameters

Name Direction Description
out out Destination string.
bv in Bitvector to convert.
alloc in Allocator to bind to the destination string.

Success

Returns true and initializes out.

Failure

Returns false if allocation fails.

Usage example (Cross-references)

Usage examples (Cross-references)
                Str bit_str;
    
                if (!BitVecTryToStrAlloc(&bit_str, bv, o->allocator)) {
                    return false;
                }
    }
    
    bool BitVecTryToStrAlloc(Str *out, BitVec *bv, Allocator alloc) {
        ValidateBitVec(bv);
        if (!out) {
        Str result;
    
        if (!BitVecTryToStrAlloc(&result, bv, alloc)) {
            result = StrInit(alloc);
        }
    #define BITVEC_TRY_TO_STR_HAS_ARGS(...)                         BITVEC_TRY_TO_STR_HAS_ARGS_IMPL(__VA_ARGS__, 3, 2, 1, 0)
    #define BitVecTryToStr(...)                                     CONCAT(BitVecTryToStr_, BITVEC_TRY_TO_STR_HAS_ARGS(__VA_ARGS__))(__VA_ARGS__)
    #define BitVecTryToStr_2(out, bv)                               BitVecTryToStrAlloc((out), (bv), BitVecGetAllocator((bv)))
    #define BitVecTryToStr_3(out, bv, alloc)                        BitVecTryToStrAlloc((out), (bv), (alloc))
    #define BitVecTryToStr(...)                                     CONCAT(BitVecTryToStr_, BITVEC_TRY_TO_STR_HAS_ARGS(__VA_ARGS__))(__VA_ARGS__)
    #define BitVecTryToStr_2(out, bv)                               BitVecTryToStrAlloc((out), (bv), BitVecGetAllocator((bv)))
    #define BitVecTryToStr_3(out, bv, alloc)                        BitVecTryToStrAlloc((out), (bv), (alloc))
    
    ///
Last updated on