Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

ElementSize

The ElementSize property is used to specify an element size, in bytes, that depends on the value of another parameter to the function. This property is allowed on Pre and Post attributes and can only be applied to pointer or array data types.

The ElementSize property must be used in conjunction with any one of the following properties:

  • ValidElements

  • ValidElementsLength

  • ValidElementsConst

  • WritableElements

  • WritableElementsConst

  • WritableElementsLength

The value of ElementSize property is a parameter to the function of type size_t. To specify an element size that is constant, use the ElementSizeConst property.

NoteNote

If size_t *count is passed as the size parameter, then ElementSize="*count" is used to specify the property value.

The following code shows the use of another parameter (size_t count) for specifying the size of each element in pc using the ElementSize property:

// C
#include <CodeAnalysis\SourceAnnotations.h>
void f ([SA_Pre(Deref=0, Null=SA_No, ElementSize="count", WritableElementsConst=3)] void *pc, size_t count);

// C++
#include <CodeAnalysis\SourceAnnotations.h>
using namespace vc_attributes;
void f ([Pre(Deref=0, Null=No, ElementSize="count", WritableElementsConst=3)] void *pc, size_t count);

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.