#[unsafe(no_mangle)]pub extern "C" fn ri_config_new() -> *mut CRiConfigExpand description
Creates a new CRiConfig instance.
Initializes an empty configuration object with no loaded sources. The configuration starts with default values and requires explicit loading from configuration sources.
§Returns
Pointer to newly allocated CRiConfig on success. Never returns NULL as the implementation uses infallible construction. The returned pointer must be freed using ri_config_free().
§Initial State
A newly created configuration:
- Contains no loaded values
- Has default values for all known keys
- Has no active configuration sources
- Is not watching for changes
§Usage Pattern
CRiConfig* config = ri_config_new();
if (config == NULL) {
// Handle allocation failure
return ERROR_MEMORY_ALLOCATION;
}
// Load from file
int load_result = ri_config_load_file(config, "config.yaml");
if (load_result != 0) {
// Handle load failure
}
// Access configuration values
char* host = ri_config_get_string(config, "server.host");
int port = ri_config_get_int(config, "server.port");
// Cleanup
ri_config_free(config);
ri_string_free(host);