MapForeachPairPtr
Description
Iterate over all stored key/value pairs with pointers.
Parameters
| Name | Direction | Description |
|---|---|---|
m |
in,out | Map to iterate over. |
key_ptr |
in | Name of pointer variable bound to the key of each pair. |
value_ptr |
in | Name of pointer variable bound to the value of each pair. |
Success
The loop body runs once per occupied slot with key_ptr bound to the in-slot key address and value_ptr bound to the in-slot value address. The body is skipped when m is empty. Use this form when the body needs to mutate the value (or read the key) through the pointer. The map is not modified by the macro itself.
Failure
The macro itself does not fail. LOG_FATAL via ValidateMap(m) when m is uninitialised or corrupted.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Debug.c:471:
if (MapAllocator(&self->live) && MapPairCount(&self->live) > 0) {
LOG_ERROR("DebugAllocator: {} live allocation(s) at deinit time:", (u64)MapPairCount(&self->live));
MapForeachPairPtr(&self->live, key_ptr, val_ptr) {
LOG_ERROR(" leaked {x} ({} bytes)", (u64)*key_ptr, (u64)val_ptr->requested_size);
debug_emit_trace(val_ptr->alloc_trace, val_ptr->alloc_trace_n, "alloc", ALLOCATOR_OF(&self->meta));- In
Debug.c:536:
StrAppendFmt(out, "DebugAllocator: {} live allocation(s):\n", (u64)MapPairCount(&self->live));
MapForeachPairPtr(&self->live, key_ptr, val_ptr) {
StrAppendFmt(out, " leak: {x} ({} bytes)\n", (u64)*key_ptr, (u64)val_ptr->requested_size);
if (val_ptr->alloc_trace_n > 0) {- In
Map.Foreach.c:33:
MapInsertR(&map, 2, 25);
MapForeachPairPtr(&map, key_ptr, value_ptr) {
key_sum += *key_ptr;
value_sum += *value_ptr;
Last updated on