John
John

Reputation: 5635

what is the difference between __deref_out_opt and __deref_opt_out?

What is the difference between the following SAL annotations?

void foo(__deref_out_opt PSTR* bar);

void foo(__deref_opt_out PSTR* bar);

Upvotes: 7

Views: 3286

Answers (1)

Ben Voigt
Ben Voigt

Reputation: 283684

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.

Upvotes: 6

Related Questions