Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What does the usage of restrict mean in the man page for 'fwrite'?

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Thanks 😀

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading