.TH "corm_handle" 3 "corm" \" -*- nroff -*- .ad l .nh .SH NAME corm_handle \- Corm open, close and save .PP \- Functions for opening, closing and saving maps\&. .SH SYNOPSIS .br .PP .SS "Functions" .in +1c .ti -1c .RI "uint32_t \fBcorm_open\fP (const char *filename, const char *database, uint32_t ktype, uint32_t vtype, uint32_t mask, uint32_t flags)" .br .RI "Open a database\&. " .ti -1c .RI "uint32_t \fBcorm_get_vtype\fP (uint32_t hd)" .br .RI "Returns the value type (vtype) of a map\&. " .ti -1c .RI "uint32_t \fBcorm_get_ktype\fP (uint32_t hd)" .br .RI "Returns the key type (ktype) of a map\&. " .ti -1c .RI "size_t \fBcorm_type_len\fP (uint32_t type_id)" .br .RI "Returns the fixed length of a type, or 0 if variable\&. " .ti -1c .RI "void \fBcorm_save\fP (void)" .br .RI "Write all file-backed maps to disk\&. " .ti -1c .RI "void \fBcorm_close\fP (uint32_t hd)" .br .RI "Close a map and free its resources\&. " .in -1c .SH "Detailed Description" .PP Functions for opening, closing and saving maps\&. .PP \fBNote\fP .RS 4 Corm uses global state and is not thread-safe\&. .PP Capacity Limits: Initial capacity is mask + 1\&. When capacity is reached, the map automatically grows (doubles) unless CM_NOGROW is set\&. Growth is transparent to callers\&. .PP Memory Allocation: Malloc failures trigger CBUG() which terminates the process immediately\&. There is no graceful error handling for out-of-memory conditions\&. .RE .PP \fBWarning\fP .RS 4 File-backed maps are automatically saved at process exit\&. Explicit \fBcorm_save()\fP calls are only needed for mid-execution persistence\&. The automatic save is triggered by a library destructor function registered during initialization\&. .RE .PP .SH "Function Documentation" .PP .SS "void corm_close (uint32_t hd)" .PP Close a map and free its resources\&. Deletes all entries, closes associated secondary maps, and frees internal structures\&. All open maps are automatically closed at process exit by the library destructor, but you can call this explicitly to free resources earlier\&. .PP \fBParameters\fP .RS 4 \fIhd\fP Handle to close\&. .RE .PP .SS "uint32_t corm_open (const char * filename, const char * database, uint32_t ktype, uint32_t vtype, uint32_t mask, uint32_t flags)" .PP Open a database\&. Creates an in-memory map and registers its handle with the internal file cache, linking it to 'filename'\&. If a file exists, it loads the map data for the specified 'database'\&. .PP \fBParameters\fP .RS 4 \fIfilename\fP Path to file or cache key\&. NULL → in-memory only\&. .br \fIdatabase\fP Logical name within file\&. NULL → skip file association\&. .br \fIktype\fP Built-in or registered key type\&. .br \fIvtype\fP Built-in or registered value type\&. .br \fImask\fP Must be 2ⁿ − 1; table size is (mask + 1)\&. .br \fIflags\fP Bitwise OR of CM_AINDEX, CM_MIRROR, CM_SORTED, etc\&. .RE .PP \fBReturns\fP .RS 4 Map handle (hd)\&. .RE .PP \fBNote\fP .RS 4 File Persistence: File-backed maps automatically load data from disk when opened, regardless of flags\&. The CM_MIRROR flag enables bidirectional lookup (creating a reverse map at handle hd + 1) which is useful for many persistence scenarios\&. The mirror map is automatically closed when closing the primary map\&. .PP Multiple databases can share a single file\&. Each database is identified by a hash of its name (XXH32)\&. Data is saved and loaded based on this database ID\&. .RE .PP .SS "void corm_save (void )" .PP Write all file-backed maps to disk\&. Walks the internal cache, computes file sizes, and performs mmap/memcpy writes for maps associated with a file\&. .PP \fBNote\fP .RS 4 This is automatically called at process exit\&. Explicit calls are only needed for mid-execution checkpointing or when you want to ensure data is persisted before continuing\&. .RE .PP .SH "Author" .PP Generated automatically by Doxygen for corm from the source code\&.