[英]SAL annotations and pointer parameters
I have been reading about SAL and I'm not clear on if annotations on pointer types apply to the reference or the value it points to. 我一直在阅读SAL ,我不清楚指针类型的注释是否适用于引用或它指向的值。 For example, if I have:
例如,如果我有:
void f(_In_ type* t);
_In_
means "The parameter must be valid in pre-state and will not be modified." _In_
表示“参数必须在预先状态下有效且不会被修改”。 Does its application here mean that the address of t will not change, or the value of t? 这里的应用是否意味着t的地址不会改变,或者t的值是多少?
In your example, _In_
means that 在您的示例中,
_In_
表示
t
is checked for null before dereferencing it in the function; t
; t
is assumed to be non-null in the function itself. t
在函数本身中是非空的。 By changing _In_
to _In_opt_
, VS Code Analysis will validate that t
is checked for null before dereferencing it. _In_
更改为_In_opt_
,VS代码分析将验证在解除引用之前检查t
是否为null。 type
from the memory pointed at by t
, like assigning the value of the dereferenced pointer to a variable. t
指向的内存中读取type
“一个元素”,例如将解除引用的指针的值赋给变量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.