Sun Java System Portal Server 7 Developer's Guide

Memory Buffer Management

You can use SOIF buffers in parsing or printing routines. They take care of memory allocation for inserting and appending. They are basically memory blocks that are easy for SOIF routines to use.

A SOIF Buffer is represented in a SOIFBuffer structure, that is created with the SOIFBuffer_Create() function and freed with the SOIFBuffer-Free() function. The SOIFBuffer structure provides the append(), increase(), and reset() functions for manipulating the data in the buffer.

SOIFBuffer_Create
NSAPI_PUBLIC SOIFBuffer *SOIFBuffer_Create(int default_sz);

The SOIFBuffer is used in SOIF_PrintInitStr(SOIFBuffer *memory). Before you can print SOIF to memory, you need to create a buffer for output.

SOIFBuffer_Free
NSAPI_PUBLIC void SOIFBuffer_Free(SOIFBuffer *sb);

Releases the memory buffer created by SOIFBuffer_Create().

append
void (*append)(SOIFBuffer *sb, char *data, int n)

Copies n bytes of data into the buffer.

increase
void (*increase)(SOIFBuffer *sb, int add_n)

Increases the size of the data buffer by add_n bytes.

reset
void (*reset)(SOIFBuffer *sb)

Resets the size of the data buffer and invalidates all currently valid data. A buffer can be reused by resetting it this way.