ValidBytes

The ValidBytes property specifies the number of bytes of an array or a buffer pointed to by a pointer that can be legally read. It is allowed on Pre and Post attributes and can only be applied to pointer or array data types.

The value of this property is an expression that involves another parameter of integral type with a range equal to or less than size_t, that determines the actual number of readable bytes.

Example

The following two samples of code show how to use the ValidBytes property:

// C 
#include <CodeAnalysis\SourceAnnotations.h>
void f([SA_Pre(ValidBytes="c") ] char *pc, size_t c);
-or-
void f([SA_Pre(ValidBytes="*c") ] char *pc, size_t *c);
// use dereference operator, size is passed as a pointer

// C++
#include <CodeAnalysis\SourceAnnotations.h>
using namespace vc_attributes;
void f([Pre(ValidBytes="c") ] char *pc, size_t c);
-or-
void f([Pre(ValidBytes="*c") ] char *pc, size_t *c);
// use dereference operator, size is passed as a pointer

ValidBytes property cannot be applied to function pointer.

See Also

Concepts

Annotation Overview

Other Resources

Annotation Properties