Results for “memory”
Small, practical examples. Search by task or narrow things down below.
Store a variable-length payload after a structure header
C: A flexible array member lets one allocation hold metadata and trailing bytes.
C✓ Tested
Store and retrieve a multibyte integer
Arduino / C: put and get copy the bytes of a typed value.
Arduino / C✓ Tested
Swap owned buffers by swapping their pointers
C: Pointer swaps avoid copying the underlying data.
C✓ Tested
Validate a small stored payload with a checksum
Arduino / C: Store a checksum with the payload and reject a changed byte.
Arduino / C✓ Tested
Allocate a zeroed array
Check calloc, use the allocation, and release it in C.
C✓ Tested
Format a decimal value
Print two fractional digits with C printf.
C✓ Tested
Hash a file without reading it all at once
Python: Feed fixed-size binary chunks into SHA-256 for files larger than memory.
Python✓ Tested
Look up values in an associative array
Use named keys for a small in-memory configuration table.
dictionary✓ Tested
Parse an integer with validation
Validate range and trailing characters when parsing a C integer with strtol.
C✓ Tested
Process a text file one line at a time
Java: Use a buffered reader to avoid loading a large file into memory.
Java✓ Tested
Set and test bit flags
Use unsigned masks to combine and test C flags.
C✓ Tested
Swap two integers
Use a temporary value to swap C integers without arithmetic overflow.
C✓ Tested