PreviousNext

Buffering Styles

There are a number of different ways in which buffers containing encoded data can be passed between the application code and the IDL encoding services. These are referred to as different buffering styles. The different buffering styles are:

· Incremental encoding

The incremental encoding style requires that you provide an allocate routine which creates an empty buffer into which IDL encoding services can place encoded data, and a write routine which IDL encoding services will call when the buffer is full or all the parameters of the operation have been encoded. The IDL encoding services call the allocate and write routines repeatedly until the encoding of all of the parameters has been delivered to the user code. See the idl_es_encode_incremental(3rpc) reference page for a description of the required parameters for the allocate and write routines.

· Fixed buffer encoding

The fixed buffer encoding style requires that the application supply a single buffer into which all the encoded data is to be placed. The buffer must have an address that is 8-byte aligned and must be a multiple of 8 bytes in size. It must also be large enough to hold an encoding of all the data, together with an encoding header for each operation whose parameters are being encoded; 56 bytes should be allowed for each encoding header.

· Dynamic buffer encoding

With the dynamic buffer encoding style, the IDL encoding services build a single buffer containing all the encoded data and deliver the buffer to application code. The buffer is allocated by whatever client memory management mechanism has been put in place by the application code. The default for this is malloc( ). When the application code no longer needs the buffer, it should release the memory resource.

The dynamic buffer encoding style has performance implications. The IDL encoding services will usually allocate a number of intermediate buffers, then allocate the buffer to be delivered to the application code, copy data into it from the intermediate buffers, and release the intermediate buffers.

· Incremental decoding

The incremental decoding buffering style requires that you provide a read routine which, when called, delivers to the IDL encoding services a buffer that contains the next part of the data to be decoded. The IDL encoding services will call the read routine repeatedly until all of the required data has been decoded. See the idl_es_encode_incremental(3rpc) reference page for a description of the required parameters for the read routine.

· Buffer decoding

The buffer decoding style requires that you supply a single buffer containing all the encoded data. Where application performance is important, note that, if the supplied buffer is not 8-byte aligned, the IDL encoding services allocate a temporary aligned buffer of comparable size and copy data from the user-supplied buffer into it before performing the requested decoding.