Reordering Identical C Struct Fields Cuts Size From 24 to 16 Bytes
cneuralnetwork · x · 2026-10-22
A developer demonstrated a classic but often-overlooked C fact: two structs with identical fields can differ in size purely due to declaration order — one takes 24 bytes, the other 16.
The cause is memory alignment: the compiler inserts padding so types land on properly aligned addresses. Ordering char→double→char forces padding after each char, while grouping the two chars together (char→char→double) needs only tail padding. Scale it up: across a million instances, simply reordering declarations saves roughly 8 MB of memory.
More from coding & agent
- OpenClaw opens its team environment to community contributors via Focus Weeks — RichardSocher · 2026-10-22
- ESA's cat keyboard incident is a warning for leaving AI agents unattended — vincent_koc · 2026-10-22
- Defense must run at machine speed: agents patch, engineers judge — saranormous · 2026-10-22
- TraceForge synthesizes reasoning traces from answers, beating Claude's own CoT by +3.7/+7.1 — IndependentResearcher121 · 2026-10-22
- Internet Archive fends off PHP attacks overnight, using Claude to patch old code — kingslyj · 2026-10-22
- Combining Ghidra, AI Reverse Engineering and WebGPU Sparks an "Absolute Renaissance" — thursdai_pod · 2026-10-22