Reference

1

Mutable Borrowing

7 minute

In C, getting a T * usually means “this code may modify the value.” The hard part is that C does not stop you from keeping many access paths alive:

uint8_t *a = buf;
uint8_t *b = buf;

a[0] = 1;
printf("%u\n", b[0]);

This code is not automatically wrong. But in real projects, several pointers reading and writing the same data make state changes hard to track. Who changed it last? Who still holds an old view? Can a function modify it before the next read?

Read More