str len: c-str bytes: size-prefix bytes: difference:
1 1+1 (4) 4+1 (8) 4
2 2+1 (4) 4+2 (8) 4
3 3+1 (4) 4+3 (8) 4
4 4+1 (8) 4+4 (8) 0
5 5+1 (8) 4+5 (12) 4
6 6+1 (8) 4+6 (12) 4
7 7+1 (8) 4+7 (12) 4
8 8+1 (12) 4+8 (12) 0
So, for example: "ABCDE" as a C-style string would require 5 bytes for the string plus one for the null terminator, which would be satisfied by an allocation of 8 bytes. An equivalent length-prefixed string would require 4 bytes for the prefix plus 5 for the string, which would then be rounded up to 12.The only time the size-prefixed variant doesn't require more memory is when the string length is a multiple of 4. So the length-prefixed version requires an additional 3 bytes on average.