IterMove
Description
Propagating move by n positions in the iteration direction. n may be negative to step backward. The new position must land in [0, length] for forward iteration, or in [-1, length) for reverse iteration (where -1 is the past-start sentinel).
Success
Position is updated, returns true.
Failure
The new position would be out of range. Position is unchanged, returns false.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
DwarfInfo.c:287:
if (!BufReadU8(cur, &n))
return false;
return IterMove(cur, (i64)(n));
}
case DW_FORM_block2 : {- In
DwarfInfo.c:293:
if (!BufReadU16LE(cur, &n))
return false;
return IterMove(cur, (i64)(n));
}
case DW_FORM_block4 : {- In
DwarfInfo.c:299:
if (!BufReadU32LE(cur, &n))
return false;
return IterMove(cur, (i64)(n));
}
case DW_FORM_block :- In
DwarfInfo.c:306:
if (!BufReadULeb128(cur, &n))
return false;
return IterMove(cur, (i64)(n));
}
case DW_FORM_indirect : {- In
Pe.c:358:
return true;
}
if (!IterMove(&c, (i64)(DIR_INDEX_DEBUG * 8u)))
return false;
// Read into a local u32, then widen -- aliasing a u64* through a
- In
Iter.c:99:
const u8 buf[4] = {5, 6, 7, 8};
BufIter it = BufIterFromMemory(buf, 4);
IterMove(&it, 2);
u8 v;
if (!IterPeekAt(&it, 0, &v) || v != 7) {- In
Iter.c:134:
const u8 buf[5] = {0};
BufIter it = BufIterFromMemory(buf, 5);
if (!IterMove(&it, 3) || IterIndex(&it) != 3) {
return false;
}- In
Iter.c:137:
return false;
}
if (!IterMove(&it, -2) || IterIndex(&it) != 1) {
return false;
}- In
Iter.c:146:
const u8 buf[3] = {0};
BufIter it = BufIterFromMemory(buf, 3);
if (!IterMove(&it, 3) || IterIndex(&it) != 3) {
return false;
}- In
Iter.c:156:
BufIter it = BufIterFromMemory(buf, 3);
size before = IterIndex(&it);
if (IterMove(&it, 4)) {
return false;
}- In
Iter.c:165:
const u8 buf[3] = {0};
BufIter it = BufIterFromMemory(buf, 3);
if (IterMove(&it, -1)) {
return false;
}- In
Iter.c:175:
BufIter it = from_rev(buf, 5);
// start at pos=4
if (!IterMove(&it, 2) || IterIndex(&it) != 2) {
return false;
}- In
Iter.c:179:
}
// step backward in reverse direction (n=-1, effective +1)
if (!IterMove(&it, -1) || IterIndex(&it) != 3) {
return false;
}- In
Iter.c:189:
BufIter it = from_rev(buf, 3);
// pos=2, dir=-1, move by 3 lands on sentinel pos=-1
if (!IterMove(&it, 3) || IterIndex(&it) != (size)-1) {
return false;
}- In
Iter.c:200:
// pos=2, dir=-1, move by 4 would land at pos=-2 — invalid
size before = IterIndex(&it);
if (IterMove(&it, 4)) {
return false;
}- In
StrIter.h:53:
/// TAGS: StrIter, Move, Position, Alias
///
#define StrIterMove(si, n) IterMove((si), (n))
///
- In
Move.h:37:
#define IterMustMove(mi, n) \
do { \
if (!IterMove((mi), (n))) { \
LOG_FATAL("IterMustMove: target position out of range"); \
} \- In
Move.h:50:
/// TAGS: Iter, Memory, Position
///
#define IterNext(mi) IterMove((mi), 1)
///
- In
Move.h:72:
/// TAGS: Iter, Memory, Position
///
#define IterPrev(mi) IterMove((mi), -1)
///
Last updated on