Skip to content

BitVecReplace

BitVecReplace

Description

Replace first occurrence of old pattern with new pattern.

Parameters

Name Direction Description
bv in Bitvector to modify
old_pattern in Pattern to find and replace
new_pattern in Pattern to replace with

Usage example (from documentation)

  bool replaced = BitVecReplace(&flags, &old_pat, &new_pat);

Returns

true if replacement was made, false if old pattern not found

Usage example (Cross-references)

Usage examples (Cross-references)
    }
    
    bool BitVecReplace(BitVec *bv, BitVec *old_pattern, BitVec *new_pattern) {
        ValidateBitVec(bv);
        ValidateBitVec(old_pattern);
    
    bool test_bitvec_replace_null_source(void) {
        WriteFmt("Testing BitVecReplace(NULL, old, new) - should fatal\n");
    
        // Don't create BitVecs since we're testing NULL source validation
    
        // Don't create BitVecs since we're testing NULL source validation
        BitVecReplace(NULL, (BitVec *)0x1, (BitVec *)0x1);
        return true;
    }
    // BitVecReplace tests
    bool test_bitvec_replace_basic(void) {
        WriteFmt("Testing BitVecReplace basic functionality\n");
    
        BitVec source      = BitVecInit();
        BitVecPush(&new_pattern, true);
    
        bool replaced = BitVecReplace(&source, &old_pattern, &new_pattern);
        result        = result && replaced;
    
    bool test_bitvec_replace_null_source(void) {
        WriteFmt("Testing BitVecReplace(NULL, old, new) - should fatal\n");
    
        // Don't create BitVecs since we're testing NULL source validation
    
        // Don't create BitVecs since we're testing NULL source validation
        BitVecReplace(NULL, (BitVec *)0x1, (BitVec *)0x1);
        return true;
    }
    // BitVecReplace tests
    bool test_bitvec_replace_basic(void) {
        WriteFmt("Testing BitVecReplace basic functionality\n");
    
        BitVec source      = BitVecInit();
        BitVecPush(&new_pattern, true);
    
        bool replaced = BitVecReplace(&source, &old_pattern, &new_pattern);
        result        = result && replaced;
Last updated on