Memory Usage
The5800 system C client library generally follows the model of populating externally allocated
datastructures such as handles, buers, and result arrays.
Someinternal data structures are generated during XML document construction. These data
structuresare allocated and freed using the function pointers supplied to hc_init when
initializingthe library (see “Initializing a Global Session” on page 41).
Otherdata structures are allocated and returned to the user; these have corresponding
functionsto free them. For example, hc_session_create_ez and hc_session_free.
UpdatingS chema DenitionsTheC client library does not automatically refresh its in-memory schema denitions. If the
schemais changed through the command-line interface (CLI), a new session must be created
witha new call to “hc_session_create_ez” on page 53 to access the schema changes.
Session ManagementAglobal 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
controlhow memory allocation occurs. You will normally supply the standard malloc,free,
andrealloc functions for this functionality.
HeapMemory Allocator
Theheap memory allocator is dened as follows:
typedef void* (*allocator_t) (size_t size);
HeapMemory Deallocator
Theheap memory deallocator is dened as follows:
typedef void (*deallocator_t) (void *p);
HeapMemory Reallocator
Theheap memory reallocator is dened as follows:
typedef void (*reallocator_t) (void *p,size_t size);
Initializinga Global Session
Thefollowing function initializes a global session:
Overviewof the 5800 System C Client API
Chapter3 • Sun StorageTek 5800 System C Client API 41