VecPtrAt
Description
Pointer to the element at idx. Use this rather than indexing data directly so element alignment is respected.
Parameters
| Name | Direction | Description |
|---|---|---|
v |
in | Vector to query. |
idx |
in | Index in [0, length). |
Usage example (Cross-references)
Usage examples (Cross-references)
- In
ArgParse.c:375:
for (u64 i = 0; i < n_specs; ++i) {
left_col[i] = StrInit(self->alloc);
left_w[i] = spec_format_left(VecPtrAt(&self->specs, i), &left_col[i]);
if (left_w[i] > max_w)
max_w = left_w[i];- In
ArgParse.c:384:
bool printed_options_header = false;
for (u64 i = 0; i < n_specs; ++i) {
ArgSpec *sp = VecPtrAt(&self->specs, i);
if (sp->role != ARG_ROLE_POSITIONAL)
continue;- In
ArgParse.c:400:
for (u64 i = 0; i < n_specs; ++i) {
ArgSpec *sp = VecPtrAt(&self->specs, i);
if (sp->role == ARG_ROLE_POSITIONAL)
continue;- In
Debug.c:211:
static const DebugFreedEntry *debug_freed_find(const DebugAllocator *dbg, void *ptr) {
for (u32 i = 0; i < VecLen(&dbg->freed); i++) {
if (VecPtrAt(&dbg->freed, i)->ptr == ptr)
return VecPtrAt(&dbg->freed, i);
}- In
Debug.c:212:
for (u32 i = 0; i < VecLen(&dbg->freed); i++) {
if (VecPtrAt(&dbg->freed, i)->ptr == ptr)
return VecPtrAt(&dbg->freed, i);
}
return NULL;- In
Graph.c:57:
static GenericGraphSlot *graph_slot_ptr_raw(GenericGraph *graph, u32 index) {
return VecPtrAt(&graph->slots, index);
}- In
Graph.c:61:
static const GenericGraphSlot *graph_slot_ptr_const_raw(const GenericGraph *graph, u32 index) {
return VecPtrAt((GraphSlots *)&graph->slots, index);
}- In
Graph.c:225:
for (idx = 0; idx < VecLen(&graph->pending_edge_removals); idx++) {
const GraphPendingEdgeRemoval *pending =
VecPtrAt((GraphPendingEdgeRemovals *)&graph->pending_edge_removals, idx);
if ((pending->from == from) && (pending->to == to)) {
return idx;- In
Graph.c:356:
for (slot_index = 0; slot_index < VecLen(&graph->slots); slot_index++) {
const GenericGraphSlot *slot = VecPtrAt((GraphSlots *)&graph->slots, slot_index);
GraphNodeId self_id = graph_make_node_id((u32)slot_index, slot->generation);
u64 neighbor_i;- In
Graph.c:423:
}
if (graph_slot_is_occupied(VecPtrAt((GraphSlots *)&graph->slots, index))) {
LOG_FATAL("Graph free index points to an occupied slot");
}- In
Graph.c:430:
for (free_index_i = 0; free_index_i < VecLen(&graph->pending_edge_removals); free_index_i++) {
const GraphPendingEdgeRemoval *pending =
VecPtrAt((GraphPendingEdgeRemovals *)&graph->pending_edge_removals, free_index_i);
const GraphNeighbors *neighbors;- In
Graph.c:474:
for (slot_index = 0; slot_index < VecLen(&graph->slots); slot_index++) {
GenericGraphSlot *slot = VecPtrAt(&graph->slots, slot_index);
if (graph_slot_is_occupied(slot)) {
graph_release_slot(graph, slot, item_size);- In
Graph.c:914:
explicit_edge_removal_count = VecLen(&graph->pending_edge_removals);
for (edge_idx = 0; edge_idx < VecLen(&graph->pending_edge_removals); edge_idx++) {
GraphPendingEdgeRemoval *pending = VecPtrAt(&graph->pending_edge_removals, edge_idx);
(void)graph_remove_edge_now(graph, pending->from, pending->to);
}- In
Graph.c:920:
for (slot_index = 0; slot_index < VecLen(&graph->slots); slot_index++) {
GenericGraphSlot *slot = VecPtrAt(&graph->slots, slot_index);
if (graph_slot_is_occupied(slot) && graph_slot_is_marked(slot)) {
GraphNodeId marked_id = graph_make_node_id((u32)slot_index, slot->generation);- In
Graph.c:928:
for (slot_index = 0; slot_index < VecLen(&graph->slots); slot_index++) {
GenericGraphSlot *slot = VecPtrAt(&graph->slots, slot_index);
if (graph_slot_is_occupied(slot) && !graph_slot_is_marked(slot)) {
GraphNodeId live_id = graph_make_node_id((u32)slot_index, slot->generation);- In
Graph.c:936:
for (slot_index = 0; slot_index < VecLen(&graph->slots); slot_index++) {
GenericGraphSlot *slot = VecPtrAt(&graph->slots, slot_index);
if (graph_slot_is_occupied(slot) && graph_slot_is_marked(slot)) {
if (VecLen(&slot->out_neighbors) || VecLen(&slot->in_neighbors)) {- In
Graph.c:980:
while (iter->slot_index < VecLen(&iter->graph->slots)) {
u32 index = (u32)iter->slot_index;
GenericGraphSlot *slot = VecPtrAt(&iter->graph->slots, iter->slot_index);
iter->slot_index += 1;- In
PdbCache.c:95:
static PdbCacheEntry *cache_find_or_open(PdbCache *self, Zstr module_path) {
for (size i = 0; i < VecLen(&self->entries); ++i) {
PdbCacheEntry *e = VecPtrAt(&self->entries, i);
if (StrBegin(&e->module_path) && ZstrCompare(StrBegin(&e->module_path), module_path) == 0) {
return e;- In
PdbCache.c:111:
return NULL;
}
return VecPtrAt(&self->entries, VecLen(&self->entries) - 1);
}- In
PdbCache.c:122:
return;
for (size i = 0; i < VecLen(&self->entries); ++i) {
PdbCacheEntry *e = VecPtrAt(&self->entries, i);
if (e->pdb_open)
PdbDeinit(&e->pdb); static ResolverCacheEntry *resolver_cache_find_or_open(SymbolResolver *self, Zstr path, u64 load_base) {
for (u64 i = 0; i < VecLen(&self->cache); ++i) {
ResolverCacheEntry *e = VecPtrAt(&self->cache, i);
if (e->path == path) {
return e; return NULL;
}
return VecPtrAt(&self->cache, VecLen(&self->cache) - 1);
} return;
for (u64 i = 0; i < VecLen(&self->cache); ++i) {
ResolverCacheEntry *e = VecPtrAt(&self->cache, i);
#if FEATURE_PARSER_DWARF
if (e->dwarf_built && e->dwarf_ok) {- In
ProcMaps.c:252:
return NULL;
for (u64 i = 0; i < VecLen(&self->entries); ++i) {
const ProcMapEntry *e = VecPtrAt(&self->entries, i);
if (addr >= e->start && addr < e->end) {
return e;- In
Dir.c:546:
bool trail_sep = (path_len > 0 && path[path_len - 1] == '/');
for (size i = 0; i < VecLen(&dc); ++i) {
DirEntry *e = VecPtrAt(&dc, i);
Zstr entry_nm = StrBegin(&e->name);
if (ZstrCompare(entry_nm, ".") == 0 || ZstrCompare(entry_nm, "..") == 0) {- In
MachoCache.c:41:
static MachoCacheEntry *cache_find_or_create(MachoCache *self, Zstr module_path) {
for (size i = 0; i < VecLen(&self->entries); ++i) {
MachoCacheEntry *e = VecPtrAt(&self->entries, i);
if (StrBegin(&e->module_path) && ZstrCompare(StrBegin(&e->module_path), module_path) == 0) {
return e;- In
MachoCache.c:57:
return NULL;
}
return VecPtrAt(&self->entries, VecLen(&self->entries) - 1);
}- In
MachoCache.c:134:
return;
for (size i = 0; i < VecLen(&self->entries); ++i) {
MachoCacheEntry *e = VecPtrAt(&self->entries, i);
if (e->fns_built && e->fns_ok)
DwarfFunctionsDeinit(&e->fns);- In
MachO.c:488:
return NULL;
for (size i = 0; i < VecLen(&self->sections); ++i) {
const MachoSection *s = VecPtrAt(&self->sections, i);
if (ZstrCompare(s->segment, segment) == 0 && ZstrCompare(s->section, section) == 0) {
return s;- In
MachO.c:513:
for (size i = 0; i < VecLen(&self->symbols); ++i) {
const MachoSymbol *s = VecPtrAt(&self->symbols, i);
if (s->type & N_STAB_MASK)
continue; // any high bit set => STAB (debug) entry
- In
Elf.c:271:
return false;
}
const ElfSection *strtab = VecPtrAt(&self->sections, strtab_idx);
if (!elf_range_ok(self, strtab->offset, strtab->size)) {
LOG_ERROR("Elf: strtab out of range");- In
Elf.c:319:
for (u64 i = 0; i < VecLen(&self->sections); ++i) {
const ElfSection *s = VecPtrAt(&self->sections, i);
if (s->type == ELF_SECTION_TYPE_SYMTAB) {
symtab = s;- In
Elf.c:507:
const ElfSymbol *best = NULL;
for (u64 i = 0; i < VecLen(syms); ++i) {
const ElfSymbol *s = VecPtrAt(syms, i);
if (s->size == 0) {
// Some symbols (e.g. labels) have zero size — only match
- In
Elf.c:540:
return NULL;
for (u64 i = 0; i < VecLen(&self->sections); ++i) {
const ElfSection *s = VecPtrAt(&self->sections, i);
if (s->name && ZstrCompare(s->name, name) == 0) {
return s;- In
Dwarf.c:643:
u64 fo = VecAt(&pending_file_offsets, i);
u64 dofs = VecAt(&pending_dir_offsets, i);
VecPtrAt(&out->entries, i)->file = fo ? (Zstr)(StrBegin(&out->string_pool) + fo) : NULL;
VecPtrAt(&out->entries, i)->dir = dofs ? (Zstr)(StrBegin(&out->string_pool) + dofs) : NULL;
}- In
Dwarf.c:644:
u64 dofs = VecAt(&pending_dir_offsets, i);
VecPtrAt(&out->entries, i)->file = fo ? (Zstr)(StrBegin(&out->string_pool) + fo) : NULL;
VecPtrAt(&out->entries, i)->dir = dofs ? (Zstr)(StrBegin(&out->string_pool) + dofs) : NULL;
}
}- In
Dwarf.c:681:
const DwarfLineEntry *seq_open = NULL;
for (u64 i = 0; i < VecLen(&self->entries); ++i) {
const DwarfLineEntry *e = VecPtrAt(&self->entries, i);
if (e->end_sequence) {
// Sequence ends at this row's address (exclusive upper).
- In
DwarfInfo.c:99:
static void abbrev_table_deinit(AbbrevTable *t) {
for (size i = 0; i < VecLen(t); ++i) {
VecDeinit(&VecPtrAt(t, i)->attrs);
}
VecDeinit(t);- In
DwarfInfo.c:161:
static const AbbrevEntry *abbrev_table_find(const AbbrevTable *t, u64 code) {
for (size i = 0; i < VecLen(t); ++i) {
if (VecPtrAt(t, i)->code == code)
return VecPtrAt(t, i);
}- In
DwarfInfo.c:162:
for (size i = 0; i < VecLen(t); ++i) {
if (VecPtrAt(t, i)->code == code)
return VecPtrAt(t, i);
}
return NULL;- In
DwarfInfo.c:379:
for (size ai = 0; ai < VecLen(&e->attrs); ++ai) {
const AbbrevAttr *a = VecPtrAt(&e->attrs, ai);
AttrVal v;
if (!read_form(&cu_cur, a->form, addr_size, &v))- In
DwarfInfo.c:610:
// has stopped growing.
for (size i = 0; i < VecLen(&pending); ++i) {
const PendingFn *pf = VecPtrAt(&pending, i);
DwarfFunction f = {
.low_pc = pf->low_pc,- In
DwarfInfo.c:665:
while (lo < hi) {
size mid = lo + (hi - lo) / 2;
if (VecPtrAt(&self->entries, mid)->low_pc <= vaddr)
lo = mid + 1;
else- In
DwarfInfo.c:672:
if (lo == 0)
return NULL;
const DwarfFunction *e = VecPtrAt(&self->entries, lo - 1);
if (vaddr >= e->low_pc && vaddr < e->high_pc)
return e;- In
Pdb.c:665:
// sizes by next-rva diff.
for (size i = 0; i < VecLen(&pending); ++i) {
const PendingPub *pp = VecPtrAt(&pending, i);
PdbFunction f = {
.rva = pp->rva,- In
Pdb.c:677:
// order. If next.rva < f.rva (impossible today), leave
// size = 0 rather than wrap.
u32 next_rva = VecPtrAt(&pending, i + 1)->rva;
f.size = next_rva >= f.rva ? next_rva - f.rva : 0;
}- In
Pdb.c:784:
while (lo < hi) {
size mid = lo + (hi - lo) / 2;
if (((const PdbFunction *)VecPtrAt(&self->functions, mid))->rva <= rva)
lo = mid + 1;
else- In
Pdb.c:791:
if (lo == 0)
return NULL;
const PdbFunction *f = VecPtrAt(&self->functions, lo - 1);
// size == 0 means "until next entry"; we already accept that case.
// Widen to u64 to avoid u32 wrap: rva and size are both u32, so a
return NULL;
for (u64 i = 0; i < VecLen(&self->cies); ++i) {
if (VecPtrAt(&self->cies, i)->offset == cie_offset) {
return VecPtrAt(&self->cies, i);
} for (u64 i = 0; i < VecLen(&self->cies); ++i) {
if (VecPtrAt(&self->cies, i)->offset == cie_offset) {
return VecPtrAt(&self->cies, i);
}
} // Linear scan -- fine up to a few thousand FDEs.
for (u64 i = 0; i < VecLen(&self->fdes); ++i) {
const DwarfFde *f = VecPtrAt(&self->fdes, i);
if (vaddr >= f->pc_begin && vaddr < f->pc_begin + f->pc_range) {
return f;- In
Pe.c:581:
return NULL;
for (size i = 0; i < VecLen(&self->sections); ++i) {
const PeSection *s = VecPtrAt(&self->sections, i);
if (ZstrCompare(s->name, name) == 0) {
return s;- In
Pe.c:599:
return false;
for (size i = 0; i < VecLen(&self->sections); ++i) {
const PeSection *s = VecPtrAt(&self->sections, i);
// Compute the section end in u64; u32 + u32 can wrap.
u64 vstart = (u64)s->virtual_address;- In
VecCharPtr.c:393:
if (VecLen(vec) > 0 && *offset + 4 <= data_size) {
size_t index = extract_u32(data, offset, data_size) % VecLen(vec);
char **ptr = VecPtrAt(vec, index);
(void)ptr; // Use the result to avoid warnings
}- In
VecStr.c:381:
if (VecLen(vec) > 0 && *offset + 4 <= data_size) {
size_t index = extract_u32(data, offset, data_size) % VecLen(vec);
Str *ptr = VecPtrAt(vec, index);
(void)ptr; // Use the result to avoid warnings
}- In
VecInt.c:326:
uint16_t idx = extract_u16(data, offset, data_size);
if (idx < VecLen(vec)) {
volatile i32 *ptr = VecPtrAt(vec, idx);
volatile i32 val = *ptr;
(void)val;- In
RoundTrip.c:429:
if (strings_match) {
for (size i = 0; i < VecLen(&original_strings); i++) {
if (StrLen(VecPtrAt(&original_strings, i)) != StrLen(VecPtrAt(&parsed_strings, i)) ||
(StrLen(VecPtrAt(&original_strings, i)) &&
StrCmp(VecPtrAt(&original_strings, i), VecPtrAt(&parsed_strings, i)) != 0)) {- In
RoundTrip.c:430:
for (size i = 0; i < VecLen(&original_strings); i++) {
if (StrLen(VecPtrAt(&original_strings, i)) != StrLen(VecPtrAt(&parsed_strings, i)) ||
(StrLen(VecPtrAt(&original_strings, i)) &&
StrCmp(VecPtrAt(&original_strings, i), VecPtrAt(&parsed_strings, i)) != 0)) {
strings_match = false;- In
RoundTrip.c:431:
if (StrLen(VecPtrAt(&original_strings, i)) != StrLen(VecPtrAt(&parsed_strings, i)) ||
(StrLen(VecPtrAt(&original_strings, i)) &&
StrCmp(VecPtrAt(&original_strings, i), VecPtrAt(&parsed_strings, i)) != 0)) {
strings_match = false;
break;- In
Str.Ops.c:213:
bool result = (VecLen(&split) == 3);
if (VecLen(&split) >= 3) {
result = result && (ZstrCompare(StrBegin(VecPtrAt(&split, 0)), "Hello") == 0);
result = result && (ZstrCompare(StrBegin(VecPtrAt(&split, 1)), "World") == 0);
result = result && (ZstrCompare(StrBegin(VecPtrAt(&split, 2)), "Test") == 0);- In
Str.Ops.c:214:
if (VecLen(&split) >= 3) {
result = result && (ZstrCompare(StrBegin(VecPtrAt(&split, 0)), "Hello") == 0);
result = result && (ZstrCompare(StrBegin(VecPtrAt(&split, 1)), "World") == 0);
result = result && (ZstrCompare(StrBegin(VecPtrAt(&split, 2)), "Test") == 0);
}- In
Str.Ops.c:215:
result = result && (ZstrCompare(StrBegin(VecPtrAt(&split, 0)), "Hello") == 0);
result = result && (ZstrCompare(StrBegin(VecPtrAt(&split, 1)), "World") == 0);
result = result && (ZstrCompare(StrBegin(VecPtrAt(&split, 2)), "Test") == 0);
}- In
Str.Ops.c:228:
// (the base-pointer of an Iter range is the Iter contract --
// direct read is the documented usage for view types).
StrIter *iter1 = VecPtrAt(&iters, 0);
char buffer1[10] = {0};
MemCopy(buffer1, iter1->data, StrIterLength(iter1));- In
Str.Ops.c:233:
result = result && (ZstrCompare(buffer1, "Hello") == 0);
StrIter *iter2 = VecPtrAt(&iters, 1);
char buffer2[10] = {0};
MemCopy(buffer2, iter2->data, StrIterLength(iter2));- In
Str.Ops.c:238:
result = result && (ZstrCompare(buffer2, "World") == 0);
StrIter *iter3 = VecPtrAt(&iters, 2);
char buffer3[10] = {0};
MemCopy(buffer3, iter3->data, StrIterLength(iter3));- In
MachO.c:136:
ok = ok && m.has_uuid && MemCompare(m.uuid, kUuid, 16) == 0;
ok = ok && VecLen(&m.segments) == 1;
ok = ok && ZstrCompare(VecPtrAt(&m.segments, 0)->name, "__TEXT") == 0;
ok = ok && VecLen(&m.sections) == 1;
ok = ok && ZstrCompare(VecPtrAt(&m.sections, 0)->section, "__text") == 0;- In
MachO.c:138:
ok = ok && ZstrCompare(VecPtrAt(&m.segments, 0)->name, "__TEXT") == 0;
ok = ok && VecLen(&m.sections) == 1;
ok = ok && ZstrCompare(VecPtrAt(&m.sections, 0)->section, "__text") == 0;
ok = ok && ZstrCompare(VecPtrAt(&m.sections, 0)->segment, "__TEXT") == 0;
ok = ok && VecLen(&m.symbols) == 1;- In
MachO.c:139:
ok = ok && VecLen(&m.sections) == 1;
ok = ok && ZstrCompare(VecPtrAt(&m.sections, 0)->section, "__text") == 0;
ok = ok && ZstrCompare(VecPtrAt(&m.sections, 0)->segment, "__TEXT") == 0;
ok = ok && VecLen(&m.symbols) == 1;
ok = ok && VecPtrAt(&m.symbols, 0)->name && ZstrCompare(VecPtrAt(&m.symbols, 0)->name, "my_function") == 0;- In
MachO.c:141:
ok = ok && ZstrCompare(VecPtrAt(&m.sections, 0)->segment, "__TEXT") == 0;
ok = ok && VecLen(&m.symbols) == 1;
ok = ok && VecPtrAt(&m.symbols, 0)->name && ZstrCompare(VecPtrAt(&m.symbols, 0)->name, "my_function") == 0;
ok = ok && VecPtrAt(&m.symbols, 0)->value == 0x100000010ull;- In
MachO.c:142:
ok = ok && VecLen(&m.symbols) == 1;
ok = ok && VecPtrAt(&m.symbols, 0)->name && ZstrCompare(VecPtrAt(&m.symbols, 0)->name, "my_function") == 0;
ok = ok && VecPtrAt(&m.symbols, 0)->value == 0x100000010ull;
MachoDeinit(&m);- In
Elf.c:81:
bool ok = false;
for (u64 i = 0; i < VecLen(&elf.symbols); ++i) {
const ElfSymbol *s = VecPtrAt(&elf.symbols, i);
if (s->type == ELF_SYMBOL_TYPE_FUNC && s->size > 0 && s->name && s->name[0] != '\0') {
ok = true;- In
SysDns.c:91:
bool got = DnsResolve(&r, "203.0.113.7:9999", SOCKET_KIND_TCP, &out);
bool ok = got && VecLen(&out) == 1 && VecPtrAt(&out, 0)->family == SOCKET_FAMILY_INET;
if (ok) {
Str s = SocketAddrFormat(VecPtrAt(&out, 0), a);- In
SysDns.c:93:
bool ok = got && VecLen(&out) == 1 && VecPtrAt(&out, 0)->family == SOCKET_FAMILY_INET;
if (ok) {
Str s = SocketAddrFormat(VecPtrAt(&out, 0), a);
ok = (StrLen(&s) > 0) && ZstrCompare(StrBegin(&s), "203.0.113.7:9999") == 0;
StrDeinit(&s);- In
SysDns.c:115:
bool got = DnsResolve(&r, "[::1]:443", SOCKET_KIND_TCP, &out);
bool ok = got && VecLen(&out) == 1 && VecPtrAt(&out, 0)->family == SOCKET_FAMILY_INET6;
if (ok) {
Str s = SocketAddrFormat(VecPtrAt(&out, 0), a);- In
SysDns.c:117:
bool ok = got && VecLen(&out) == 1 && VecPtrAt(&out, 0)->family == SOCKET_FAMILY_INET6;
if (ok) {
Str s = SocketAddrFormat(VecPtrAt(&out, 0), a);
// SocketAddrFormat emits the bracketed form for IPv6.
ok = (StrLen(&s) > 0) && ZstrCompare(StrBegin(&s), "[::1]:443") == 0;- In
AllocDebug.c:187:
// `DebugFreedEntry` structs with no public accessor; reach in to
// confirm each entry carries the ptr + both traces.
ok = ok && (VecPtrAt(&dbg.freed, 0)->ptr == p1) && (VecPtrAt(&dbg.freed, 0)->requested_size == 16);
ok = ok && (VecPtrAt(&dbg.freed, 0)->alloc_trace_n > 0) && (VecPtrAt(&dbg.freed, 0)->free_trace_n > 0);
ok = ok && (VecPtrAt(&dbg.freed, 2)->ptr == p3) && (VecPtrAt(&dbg.freed, 2)->requested_size == 64);- In
AllocDebug.c:188:
// confirm each entry carries the ptr + both traces.
ok = ok && (VecPtrAt(&dbg.freed, 0)->ptr == p1) && (VecPtrAt(&dbg.freed, 0)->requested_size == 16);
ok = ok && (VecPtrAt(&dbg.freed, 0)->alloc_trace_n > 0) && (VecPtrAt(&dbg.freed, 0)->free_trace_n > 0);
ok = ok && (VecPtrAt(&dbg.freed, 2)->ptr == p3) && (VecPtrAt(&dbg.freed, 2)->requested_size == 64);- In
AllocDebug.c:189:
ok = ok && (VecPtrAt(&dbg.freed, 0)->ptr == p1) && (VecPtrAt(&dbg.freed, 0)->requested_size == 16);
ok = ok && (VecPtrAt(&dbg.freed, 0)->alloc_trace_n > 0) && (VecPtrAt(&dbg.freed, 0)->free_trace_n > 0);
ok = ok && (VecPtrAt(&dbg.freed, 2)->ptr == p3) && (VecPtrAt(&dbg.freed, 2)->requested_size == 64);
DebugAllocatorDeinit(&dbg); BitVecPush(&source, true);
BitVec *p0 = VecPtrAt(&patterns, 0);
BitVec *p1 = VecPtrAt(&patterns, 1);
BitVec *p2 = VecPtrAt(&patterns, 2);
BitVec *p0 = VecPtrAt(&patterns, 0);
BitVec *p1 = VecPtrAt(&patterns, 1);
BitVec *p2 = VecPtrAt(&patterns, 2); BitVec *p0 = VecPtrAt(&patterns, 0);
BitVec *p1 = VecPtrAt(&patterns, 1);
BitVec *p2 = VecPtrAt(&patterns, 2);
*p0 = BitVecInit(ALLOCATOR_OF(&alloc)); BitVecPush(&source, true);
BitVec *p0 = VecPtrAt(&patterns, 0);
BitVec *p1 = VecPtrAt(&patterns, 1);
BitVec *p2 = VecPtrAt(&patterns, 2);
BitVec *p0 = VecPtrAt(&patterns, 0);
BitVec *p1 = VecPtrAt(&patterns, 1);
BitVec *p2 = VecPtrAt(&patterns, 2); BitVec *p0 = VecPtrAt(&patterns, 0);
BitVec *p1 = VecPtrAt(&patterns, 1);
BitVec *p2 = VecPtrAt(&patterns, 2);
*p0 = BitVecInit(ALLOCATOR_OF(&alloc));- In
ProcMaps.c:23:
bool any_exec = false;
for (u64 i = 0; i < VecLen(&maps.entries); ++i) {
if (VecPtrAt(&maps.entries, i)->perms & PROC_MAP_PERM_EXEC) {
any_exec = true;
break;- In
Graph.Init.c:56:
// `graph.slots` is the typed `Vec(GraphSlot(int))`, so iterate via
// the runtime-shared layout to avoid an anonymous-struct annotation.
GenericGraphSlot *slot = (GenericGraphSlot *)VecPtrAt(&GENERIC_GRAPH(&graph)->slots, slot_index);
result = result && (slot->data == NULL);
result = result && (slot->visit_count == 0);- In
Graph.Init.c:64:
}
result = result && (VecPtrAt(&graph.slots, GraphNodeIdIndex(first_id))->generation == (first_generation + 1));
result = result && (VecPtrAt(&graph.slots, GraphNodeIdIndex(second_id))->generation == (second_generation + 1));
result = result && (VecPtrAt(&graph.slots, GraphNodeIdIndex(third_id))->generation == (third_generation + 1));- In
Graph.Init.c:65:
result = result && (VecPtrAt(&graph.slots, GraphNodeIdIndex(first_id))->generation == (first_generation + 1));
result = result && (VecPtrAt(&graph.slots, GraphNodeIdIndex(second_id))->generation == (second_generation + 1));
result = result && (VecPtrAt(&graph.slots, GraphNodeIdIndex(third_id))->generation == (third_generation + 1));- In
Graph.Init.c:66:
result = result && (VecPtrAt(&graph.slots, GraphNodeIdIndex(first_id))->generation == (first_generation + 1));
result = result && (VecPtrAt(&graph.slots, GraphNodeIdIndex(second_id))->generation == (second_generation + 1));
result = result && (VecPtrAt(&graph.slots, GraphNodeIdIndex(third_id))->generation == (third_generation + 1));
GraphDeinit(&graph); result = result && VecLen(&runs) == 5;
if (result) {
result = result && VecPtrAt(&runs, 0)->length == 3 && VecPtrAt(&runs, 0)->value == true;
result = result && VecPtrAt(&runs, 1)->length == 2 && VecPtrAt(&runs, 1)->value == false;
result = result && VecPtrAt(&runs, 2)->length == 1 && VecPtrAt(&runs, 2)->value == true; if (result) {
result = result && VecPtrAt(&runs, 0)->length == 3 && VecPtrAt(&runs, 0)->value == true;
result = result && VecPtrAt(&runs, 1)->length == 2 && VecPtrAt(&runs, 1)->value == false;
result = result && VecPtrAt(&runs, 2)->length == 1 && VecPtrAt(&runs, 2)->value == true;
result = result && VecPtrAt(&runs, 3)->length == 1 && VecPtrAt(&runs, 3)->value == false; result = result && VecPtrAt(&runs, 0)->length == 3 && VecPtrAt(&runs, 0)->value == true;
result = result && VecPtrAt(&runs, 1)->length == 2 && VecPtrAt(&runs, 1)->value == false;
result = result && VecPtrAt(&runs, 2)->length == 1 && VecPtrAt(&runs, 2)->value == true;
result = result && VecPtrAt(&runs, 3)->length == 1 && VecPtrAt(&runs, 3)->value == false;
result = result && VecPtrAt(&runs, 4)->length == 1 && VecPtrAt(&runs, 4)->value == true; result = result && VecPtrAt(&runs, 1)->length == 2 && VecPtrAt(&runs, 1)->value == false;
result = result && VecPtrAt(&runs, 2)->length == 1 && VecPtrAt(&runs, 2)->value == true;
result = result && VecPtrAt(&runs, 3)->length == 1 && VecPtrAt(&runs, 3)->value == false;
result = result && VecPtrAt(&runs, 4)->length == 1 && VecPtrAt(&runs, 4)->value == true;
} result = result && VecPtrAt(&runs, 2)->length == 1 && VecPtrAt(&runs, 2)->value == true;
result = result && VecPtrAt(&runs, 3)->length == 1 && VecPtrAt(&runs, 3)->value == false;
result = result && VecPtrAt(&runs, 4)->length == 1 && VecPtrAt(&runs, 4)->value == true;
}- In
Vec.Access.c:61:
// Test VecPtrAt function
bool test_vec_ptr_at(void) {
WriteFmt("Testing VecPtrAt\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Vec.Access.c:75:
// Get pointers to elements
int *ptr0 = VecPtrAt(&vec, 0);
int *ptr1 = VecPtrAt(&vec, 1);
int *ptr2 = VecPtrAt(&vec, 2);- In
Vec.Access.c:76:
// Get pointers to elements
int *ptr0 = VecPtrAt(&vec, 0);
int *ptr1 = VecPtrAt(&vec, 1);
int *ptr2 = VecPtrAt(&vec, 2);- In
Vec.Access.c:77:
int *ptr0 = VecPtrAt(&vec, 0);
int *ptr1 = VecPtrAt(&vec, 1);
int *ptr2 = VecPtrAt(&vec, 2);
// Check values through pointers
- In
Pdb.c:295:
ok = VecLen(&pdb.functions) == 1;
if (ok) {
const PdbFunction *f = VecPtrAt(&pdb.functions, 0);
ok = ok && f->rva == 0x1100 && f->name && ZstrCompare(f->name, "my_function") == 0;
}- In
Dns.c:159:
if (match) {
DnsRecord *r0 = VecPtrAt(&resp.answers, 0);
match = r0->type == DNS_TYPE_A && r0->ttl == 300 && r0->ipv4[0] == 93 && r0->ipv4[1] == 184 &&
r0->ipv4[2] == 216 && r0->ipv4[3] == 34 && StrLen(&r0->name) > 0 &&- In
Dns.c:165:
}
if (match) {
DnsRecord *r1 = VecPtrAt(&resp.answers, 1);
match = r1->type == DNS_TYPE_AAAA && r1->ipv6[0] == 0x26 && r1->ipv6[1] == 0x06 && r1->ipv6[14] == 0x19 &&
r1->ipv6[15] == 0x46;- In
Dns.c:294:
bool match = ok && VecLen(&resp.answers) == 1;
if (match) {
DnsRecord *r = VecPtrAt(&resp.answers, 0);
match = r->type == DNS_TYPE_CNAME && StrLen(&r->target) > 0 &&
ZstrCompare(StrBegin(&r->target), "example.com") == 0; WriteFmt("Testing BitVecPrefixMatch(NULL, patterns, 1) - should fatal\n");
BitVecs vp = VecInitWithDeepCopy(NULL, BitVecDeinit, ALLOCATOR_OF(&alloc));
BitVecPush(VecPtrAt(&vp, 0), true);
BitVecPrefixMatch(NULL, &vp);
VecDeinit(&vp); WriteFmt("Testing BitVecSuffixMatch(NULL, patterns, 1) - should fatal\n");
BitVecs vp = VecInitWithDeepCopy(NULL, BitVecDeinit, ALLOCATOR_OF(&alloc));
BitVecPush(VecPtrAt(&vp, 0), true);
BitVecSuffixMatch(NULL, &vp);
VecDeinit(&vp);- In
Pe.c:170:
ok = pe.machine == PE_MACHINE_X86_64 && pe.is_pe32_plus && pe.image_base == 0x140000000ull;
ok = ok && VecLen(&pe.sections) == 1;
ok = ok && ZstrCompare(VecPtrAt(&pe.sections, 0)->name, ".debug") == 0;
ok = ok && VecPtrAt(&pe.sections, 0)->virtual_address == SECTION_VA;
ok = ok && pe.codeview.present;- In
Pe.c:171:
ok = ok && VecLen(&pe.sections) == 1;
ok = ok && ZstrCompare(VecPtrAt(&pe.sections, 0)->name, ".debug") == 0;
ok = ok && VecPtrAt(&pe.sections, 0)->virtual_address == SECTION_VA;
ok = ok && pe.codeview.present;
ok = ok && pe.codeview.age == 0x2a;- In
Foreach.h:85:
if ((ValidateVec(UNPL(pv)), 1) && UNPL(pv)->length > 0) \
for (u64 idx = 0, UNPL(d) = 1; UNPL(d); UNPL(d)--) \
for (VEC_DATATYPE(UNPL(pv)) *var = NULL; idx < UNPL(pv)->length && (var = VecPtrAt(UNPL(pv), idx), 1); \
idx++)- In
Foreach.h:112:
for (u64 idx = UNPL(pv)->length; idx-- > 0 && idx < UNPL(pv)->length;) \
for (u8 UNPL(run_once) = 1; UNPL(run_once); UNPL(run_once) = 0) \
for (VEC_DATATYPE(UNPL(pv)) *var = VecPtrAt(UNPL(pv), idx); UNPL(run_once); UNPL(run_once) = 0)
///
- In
Foreach.h:220:
idx >= UNPL(s) && idx < UNPL(e) && idx < UNPL(pv)->length && UNPL(s) <= UNPL(e); \
++idx, UNPL(d) = 1) \
for (VEC_DATATYPE(UNPL(pv)) *var = VecPtrAt(UNPL(pv), idx); UNPL(d); UNPL(d) = 0)
///
- In
Access.h:118:
/// TAGS: Str, Access, Index, Pointer
///
#define StrCharPtrAt(str, idx) VecPtrAt(str, idx)
///
Last updated on