I was looking a the man page for fwrite, and I was curious about the usage of restrict for the arguments as I have no seen this before.
size_t fwrite(const void ptr[restrict .size * .nmemb]...
what does the .size * .nmemb
mean here? are we restricting the allowed size of ptr
?
I was hoping I could use this to better my own code in terms of safety when using void pointers.
Thanks :D
restrict
is a keyword indicating that no other argument should point to or be found in an area of the buffer pointed by ptr
. This allows optimizations.
.size * .nmemb
is pseudocode indicating the size of the buffer is expected to be (at least) as big as the result of the multiplication of value of the size
and nmemb
parameters.