I'm not sure if this is this right place to ask this question, so please migrate this post to a correct place if it suits better.
I was really wondering what is a correct name for this.
char buf[SIZE + XX]
buf
will contain meaningful data up to SIZE
but some routines will write over SIZE
so I should provide a buffer XX
for the overflow.
What do you think is a good name for XX
?
It's called padding.
Take for example
struct Struct {
int i;
char ch;
}
On a particular system with sizeof( int )
of 4
, sizeof( struct Struct )
might be 8
. That's because 3 bytes of padding are added (on that system) at the end to ensure that each element of arrays of this struct are properly aligned.
Take for example encryption protocols. It's common for them to work with fixed-size blocks. The modern standard for symmetric encryption is such a protocol. AES can only encode and decode 128 bit blocks. So what if the data you want to send isn't a multiple of 128 bits? Padding must be used.
In the first example, padding refers to extra space required to meet meta/sizing constraints rather than for storing data.
In the second example, padding refers to extra data required to meet meta/sizing constraints rather than for carrying information.
In both examples, padding refers to something extra added solely to meet meta/sizing constraints. And this is what you are adding.
Finally, things it's not. "Overflow" refers to insufficient space. "Safety" implies guesswork or uncertainty. Neither term is appropriate here.