Sun Java System Portal Server 7.1 Developer's Guide

Memory Buffer Management

You can use Search 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 Search routines to use.

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

SearchBuffer_Create

NSAPI_PUBLIC SearchBuffer *
SearchBuffer_Create(int default_sz);

The SearchBuffer is used in Search_PrintInitStr(SearchBuffer *memory). Before you can print Search to memory, you need to create a buffer for output.

SearchBuffer_Free

NSAPI_PUBLIC void SearchBuffer_Free
(SearchBuffer *sb);

Releases the memory buffer created by SearchBuffer_Create().

append

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

Copies n bytes of data into the buffer.

increase

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

Increases the size of the data buffer by add_n bytes.

reset

void (*reset)(SearchBuffer *sb)

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