BitVecPrefixMatch

Table of Contents

BitVecPrefixMatch

Description

Match bitvector against an array of prefix patterns. Returns the index of the first matching prefix.

Parameters

NameDirectionDescription
bvinBitVec to check
patternsinVec(BitVec) to check prefices against

Usage example (from documentation)

  BitVec prefixes[3] = { pattern1, pattern2, pattern3 };
  u64 match = BitVecPrefixMatch(&data, prefixes, 3);

Usage example (Cross-references)

    }
    
    u64 BitVecPrefixMatch(BitVec *bv, BitVecs *patterns) {
    ValidateBitVec(bv);
    if (!patterns) {
    
    bool test_bitvec_prefix_match_null_source(void) {
    printf("Testing BitVecPrefixMatch(NULL, patterns, 1) - should fatal\n");
    BitVecs vp = VecInitWithDeepCopy(NULL, BitVecDeinit);
    BitVecPush(VecPtrAt(&vp, 0), true);
    BitVecs vp = VecInitWithDeepCopy(NULL, BitVecDeinit);
    BitVecPush(VecPtrAt(&vp, 0), true);
    BitVecPrefixMatch(NULL, &vp);
    VecDeinit(&vp);
    return true;
    
    bool test_bitvec_prefix_match_null_patterns(void) {
    printf("Testing BitVecPrefixMatch(source, NULL, 1) - should fatal\n");
    BitVec source = BitVecInit();
    BitVecPush(&source, true);
    BitVec source = BitVecInit();
    BitVecPush(&source, true);
    BitVecPrefixMatch(&source, NULL);
    BitVecDeinit(&source);
    return true;
    // BitVecPrefixMatch tests
    bool test_bitvec_prefix_match_basic(void) {
    printf("Testing BitVecPrefixMatch basic functionality\n");
    
    BitVec  source   = BitVecInit();
    BitVecPush(p2, true);
    
    u64 match_idx = BitVecPrefixMatch(&source, &patterns);
    result        = result && (match_idx == 1);
    // BitVecPrefixMatch tests
    bool test_bitvec_prefix_match_basic(void) {
    printf("Testing BitVecPrefixMatch basic functionality\n");
    
    BitVec source = BitVecInit();
    BitVecPush(&patterns[2], true);
    
    u64 match_idx = BitVecPrefixMatch(&source, patterns, 3);
    result        = result && (match_idx == 1);
    
    bool test_bitvec_prefix_match_null_source(void) {
    printf("Testing BitVecPrefixMatch(NULL, patterns, 1) - should fatal\n");
    BitVec patterns[1] = {BitVecInit()};
    BitVecPush(&patterns[0], true);
    BitVec patterns[1] = {BitVecInit()};
    BitVecPush(&patterns[0], true);
    BitVecPrefixMatch(NULL, patterns, 1);
    BitVecDeinit(&patterns[0]);
    return true;
    
    bool test_bitvec_prefix_match_null_patterns(void) {
    printf("Testing BitVecPrefixMatch(source, NULL, 1) - should fatal\n");
    BitVec source = BitVecInit();
    BitVecPush(&source, true);
    BitVec source = BitVecInit();
    BitVecPush(&source, true);
    BitVecPrefixMatch(&source, NULL, 1);
    BitVecDeinit(&source);
    return true;

Share :

Related Posts

BitVecReplace

BitVecReplace Description Replace first occurrence of old pattern with new pattern.

Read More

BitVecReplaceAll

BitVecReplaceAll Description Replace all occurrences of old pattern with new pattern.

Read More

BitVecRegexMatch

BitVecRegexMatch Description Simple regex-style pattern matching for bitvectors. Supports basic patterns: ‘*’ (any sequence), ‘?’ (0 or 1), ‘[01]’ (literal).

Read More