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 */
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

Multiple Levels of Pointers