BitVecCountPattern
Description
Count total occurrences of a bit pattern in the bitvector.
Parameters
| Name | Direction | Description |
|---|---|---|
bv |
in | Bitvector to search in |
pattern |
in | Pattern to count |
Usage example (from documentation)
u64 count = BitVecCountPattern(&flags, &pattern);Success
Number of occurrences found
Failure
Returns 0 when the pattern never matches or is longer than bv.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
BitVec.c:1758:
}
u64 BitVecCountPattern(BitVec *bv, BitVec *pattern) {
ValidateBitVec(bv);
ValidateBitVec(pattern); BitVecPush(&pattern, true);
BitVecCountPattern(NULL, &pattern); // Should LOG_FATAL
BitVecDeinit(&pattern); BitVecPush(&source, true);
BitVecCountPattern(&source, NULL); // Should LOG_FATAL
BitVecDeinit(&source); DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVecCountPattern basic functionality\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc)); BitVecPush(&pattern, true);
u64 count = BitVecCountPattern(&source, &pattern);
result = result && (count == 4); BitVecPush(&pattern, false);
count = BitVecCountPattern(&source, &pattern);
result = result && (count == 3); push_bits(&pattern, "101");
bool result = (BitVecCountPattern(&source, &pattern) == 1);
BitVecDeinit(&source);
Last updated on