The size-related attributes max_is and size_is determine how many array elements the server stub allocates on the server.
The length-related attributes length_is, first_is, and last_is determine how many elements are transmitted to both the server and the client.
Different directional attribute(s) can be applied to a declarator and the parameter specified by a field attribute. However, some combinations of different directional attributes can cause errors when they are applied to the declarator and to the field attribute parameter.
As an example, consider a procedure with two parameters, an array, and the transmitted length of the array. The italicized term dir_attr refers to the directional attribute applied to the parameter as:
Proc1(
[dir_attr] short * plength;
[dir_attr, length_is(pLength)] short array[MAX_SIZE]);
The MIDL compiler behavior for each combination of directional attributes is described below:
Array |
Length parameter | Stub actions during call from client to server |
Stub actions on return from server to client |
---|---|---|---|
in | in | Transmit the length and the number of elements indicated by the parameter. | No data transmitted. |
in | out | Not legal; MIDL compiler error. | Not legal; MIDL compiler error. |
in | in, out | Transmit the length and the number of elements indicated by the length parameter. | Transmit the length only. |
out | in | Transmit the length. If array size is fixed, allocate the array size on the server, but transmit no elements. If array size is not bound, not legal: MIDL compiler error. |
Transmit the number of elements indicated by the length. Note that the length can be changed and can have a different value from the value on the client. Do not transmit the length. |
out | out | Allocate space for the length parameter on the server but do not transmit the parameter. If the array size is fixed, allocate the array size on the server, but transmit no elements. If array size is not fixed, not legal: MIDL compiler error. |
Transmit the length and the number of elements indicated by the length as set by the server application. |
out | in, out | Transmit the length parameter. If the array size is bound, allocate the array size on the server, but transmit no elements. If array size is not bound, not legal: MIDL compiler error. |
Transmit the length. Transmit the number of array elements indicated by the length. |
in, out | in | Transmit the length and the number of elements indicated by the parameter. | Do not transmit the length. Transmit the number of elements indicated by the length. Note that the length can be changed and can have a different value from the original value on the client. |
in, out | out | Not legal; MIDL compiler error. | Not legal; MIDL compiler error. |
in, out | in, out | Transmit the length and the number of elements indicated by the parameter. | Transmit the length and the number of elements indicated by the parameter. |
In general, you should not modify the length or size parameters on the server side. If you change the length parameter, you can orphan memory. For more information, see Memory Orphaning.