Connected: An Internet Encyclopedia
RFC 1832 - 3.13 Variable-length Array

Top: Connected: An Internet Encyclopedia
Up: Requests For Comments
Up: RFC 1832
Up: 3. XDR DATA TYPES
Prev: 3.12 Fixed-length Array
Next: 3.14 Structure

### 3.13 Variable-length Array

Counted arrays provide the ability to encode variable-length arrays of homogeneous elements. The array is encoded as the element count n (an unsigned integer) followed by the encoding of each of the array's elements, starting with element 0 and progressing through element n- 1. The declaration for variable-length arrays follows this form:

             type-name identifier<m>;
          or
             type-name identifier<>;

The constant m specifies the maximum acceptable element count of an array; if m is not specified, as in the second declaration, it is assumed to be (2**32) - 1.

               0  1  2  3
             +--+--+--+--+--+--+--+--+--+--+--+--+...+--+--+--+--+
             |     n     | element 0 | element 1 |...|element n-1|
             +--+--+--+--+--+--+--+--+--+--+--+--+...+--+--+--+--+
             |<-4 bytes->|<--------------n elements------------->|
                                                             COUNTED ARRAY

It is an error to encode a value of n that is greater than the maximum described in the specification.

Next: 3.14 Structure

Connected: An Internet Encyclopedia
RFC 1832 - 3.13 Variable-length Array