While reading Advanced Programming in the UNIX Environment, I noticed this:

#include <stdio.h>
FILE* fmemopen(void *restrict buf, size_t size, const char *restrict type);

What is the keyword restrict for?

One of the new features in the recently approved C standard C99, is the restrict pointer qualifier. This qualifier can be applied to a data pointer to indicate that, during the scope of that pointer declaration, all data accessed through it will be accessed only through that pointer but not through any other pointer. The 'restrict' keyword thus enables the compiler to perform certain optimizations based on the premise that a given object cannot be changed through another pointer. Now you're probably asking yourself, "doesn't const already guarantee that?" No, it doesn't. The qualifier const ensures that a variable cannot be changed through a particular pointer. However, it's still possible to change the variable through a different pointer.

So this keyword is used to help the compiler to perform optimizations. Here is an example:

int foo(int* x, int* y)
{
   *x = 0;
   *y = 1;
   return *x;
}

Will function foo() return 0? If so, apparently the compiler can use the following code to replace it:

int foo(int x, int y)
{
*x = 0;
*y = 1;
return 0;
}
But, the compiler can not do that. Because x and y may point to the same data. In this case, we want foo() return 1.

Now, with the help of restrict, the compiler can perform optimizations safely.

int foo(int *restrict x, int *restrict y)
{
   *x = 0;
   *y = 1;
   return *x;
}

The pointer x is the only way to change *x. So the compiler can perform the following optimization:

int foo(int *restrict x, int *restrict y)
{
    *x = 0;
    *y = 1;
    return 0;
}

Notice that only C99(not c++) support the qualifier restrict.