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);Success
true if a replacement was made; bv reflects the new bits.
Failure
false if old_pattern was not found or the rewrite could not allocate; on allocator OOM bv is left in its pre-call state.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
BitVec.c:1741:
}
bool BitVecReplace(BitVec *bv, BitVec *old_pattern, BitVec *new_pattern) {
ValidateBitVec(bv);
ValidateBitVec(old_pattern); DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVecReplace basic functionality\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc)); 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;
}
Last updated on