Skip to content

IterTruncate

Description

Bound the iterator so only n further elements are reachable from the current position. Caps length at pos + n; subsequent IterRead/IterPeekAt/IterMove calls treat the new tail as past-the-end. Use when a structural field (e.g. a Mach-O cmdsize) tells you the in-memory record ends earlier than the underlying buffer.

Usage example (Cross-references)

Usage examples (Cross-references)
        BufIter walker = BufIterFromBuf(&ctx->out->data);
        IterMustMove(&walker, MH_HEADER_64_SIZE);
        IterTruncate(&walker, ctx->sizeofcmds);
    
        for (u32 i = 0; i < ctx->ncmds; ++i) {
        BufIter   tab      = BufIterFromBuf(&ctx->out->data);
        IterMustMove(&tab, ctx->symoff);
        IterTruncate(&tab, (u64)ctx->nsyms * NLIST64_SIZE);
        for (u32 i = 0; i < ctx->nsyms; ++i) {
            u32 n_strx;
Last updated on