Question

What is the difference between the following SAL annotations?

void foo(__deref_out_opt PSTR* bar);

void foo(__deref_opt_out PSTR* bar);
Was it helpful?

Solution

A PSTR* out parameter means the caller passes in a buffer which receives a pointer to a string.

In __deref_out_opt, the string is optional (the function puts NULL in the caller-provided buffer).

In __deref_opt_out, the buffer is optional (the caller passes NULL to indicate disinterest in the output value).

Presumably, it's possible to combine these concepts, there should be a __deref_opt_out_opt modifier for that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top