The size_is Attribute

The size_is attribute is associated with an integer constant, expression, or variable that specifies the allocation size of the array. Consider a character array whose length is determined by user input:

/* IDL file */
[ uuid(20B309B1-015C-101A-B308-02608C4C9B53),
  version(2.0)
]
interface arraytest
{
void fArray2([in] short sSize,
             [in, out, size_is(sSize)] char achArray[*]);
}
 

The asterisk (*) that marks the placeholder for the variable-array dimension is optional.

The server stub must allocate memory on the server that corresponds to the memory on the client for that parameter. The variable that specifies the size must always be at least an in parameter. The in directional attribute is required so that the size value is defined on entry to the server stub. This size value provides information that the server stub requires to allocate the memory. The size parameter can also be in, out.

See Also

Multiple Levels of Pointers