So we've got our struct. Imagine augmenting it with a bool called mark
:
struct Foo {
bool mark;
int data_size;
char[] data;
}
So we can walk through the pool of Foo
s that begins at buffer
and ends at end
:
while (iter < end) {
Foo *block = (Foo *)iter;
printf(“I’ve got a block of size %d. She is %s. She encodes: %s.”,
block->size, block->mark ? "marked" : "not marked", block->data);
iter += sizeof(struct Foo) + block->size;
}
Imagine I wanted to compact this buffer, removing all the structs which have mark == false
...