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(ba209999-0c6c-11d2-97cf-00c04f8eea45),
version(2.0)
]
interface arraytest
{
void fArray2([in] short sSize,
[in, out, size_is(sSize)] char achArray[*]);
}
Note
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]. This is useful if, for instance, the array the client sends is not large enough for the data that the server needs to store in it. You can use an [in, out] size parameter to send the required size back to the client program.
Related topics
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for