Skip to content
BitVecMatchIndices

BitVecMatchIndices

Description

Vec-flavoured handle for a sequence of bit-pattern match indices. Consumed by the Vec form of BitVecFindAllPattern.

Usage example (Cross-references)

Usage examples (Cross-references)
        ///
        u64  bitvec_find_all_pattern_raw(BitVec *bv, BitVec *pattern, size *results, u64 max_results);
        bool bitvec_find_all_pattern_vec(BitVec *bv, BitVec *pattern, BitVecMatchIndices *out);
    
    #define BitVecFindAllPattern(...)                         OVERLOAD(BitVecFindAllPattern, __VA_ARGS__)
    }
    
    bool bitvec_find_all_pattern_vec(BitVec *bv, BitVec *pattern, BitVecMatchIndices *out) {
        ValidateBitVec(bv);
        ValidateBitVec(pattern);
    
        if (!out || !out->allocator) {
            LOG_FATAL("output BitVecMatchIndices is NULL or uninitialized");
        }
        BitVecPush(&pattern, true);
    
        BitVecMatchIndices matches = VecInitT(matches, base);
        result                     = result && BitVecFindAllPattern(&source, &pattern, &matches);
        result                     = result && VecLen(&matches) == 5;
        BitVecPush(&pattern, false);
    
        BitVecMatchIndices matches = VecInitT(matches, base);
        result                     = result && BitVecFindAllPattern(&source, &pattern, &matches);
        // Exact-length match: exactly one hit, at index 0.
        BitVecPush(&pattern, true);
    
        BitVecMatchIndices matches = VecInitT(matches, base);
        BitVecFindAllPattern(NULL, &pattern, &matches);
        return true; // Should never reach here.
        BitVecPush(&source, true);
    
        BitVecMatchIndices matches = VecInitT(matches, base);
        BitVecFindAllPattern(&source, NULL, &matches);
        return true; // Should never reach here.
Last updated on