Overview of the 5800 System C Client API

Memory Usage

The 5800 system C client library generally follows the model of populating externally allocated data structures such as handles, buffers, and result arrays.

Some internal data structures are generated during XML document construction. These data structures are allocated and freed using the function pointers supplied to hc_init when initializing the library (see “Initializing a Global Session” on page 41).

Other data structures are allocated and returned to the user; these have corresponding functions to free them. For example, hc_session_create_ez and hc_session_free.

Updating Schema Definitions

The C client library does not automatically refresh its in-memory schema definitions. If the schema is changed through the command-line interface (CLI), a new session must be created with a new call to “hc_session_create_ez” on page 53 to access the schema changes.

Session Management

A global session must be explicitly initialized with a call to hc_init and released with a call to hc_cleanup. Memory allocators and deallocators are supplied in the initialization function to control how memory allocation occurs. You will normally supply the standard malloc, free, and realloc functions for this functionality.

Heap Memory Allocator

The heap memory allocator is defined as follows:

typedef void* (*allocator_t) (size_t size);

Heap Memory Deallocator

The heap memory deallocator is defined as follows:

typedef void (*deallocator_t) (void *p);

Heap Memory Reallocator

The heap memory reallocator is defined as follows:

typedef void (*reallocator_t) (void *p,size_t size);

Initializing a Global Session

The following function initializes a global session:

Chapter 3 • Sun StorageTek 5800 System C Client API

41

Page 41
Image 41
Sun Microsystems 5800 manual Memory Usage, Updating Schema Definitions, Session Management