1: .TH LC_GETERRNO 3 "25 Oct 04" "@PACKAGE_STRING@" 2: .SH NAME 3: lc_cleanup \- Clean up internal structures after processing data. 4: 5: .SH SYNOPSIS 6: .B #include <libconfig.h> 7: .sp 8: .BI "void lc_cleanup(void);" 9: 10: .SH DESCRIPTION 11: The 12: .BR lc_cleanup (3) 13: function cleans up the internal structures created by calling 14: .BR lc_register_var (3) 15: or 16: .BR lc_register_callback (3) 17: and returns the memory to the application. It is not strictly required, however memory concious programmers will still want to call this after finishing processing configuration files. 18: 19: After you call 20: .BR lc_cleanup (3) 21: calling 22: .BR lc_process (3) 23: or 24: .BR lc_process_file (3) 25: will generally cause errors since the registered variables and callbacks have been unregistered. 26: 27: .SH EXAMPLE 28: .nf 29: #include <libconfig.h> 30: #include <stdlib.h> 31: #include <stdio.h> 32: 33: int main(int argc, char **argv) { 34: int lc_p_ret, lc_rv_ret; 35: char *filename = NULL; 36: 37: lc_rv_ret = lc_register_var("File", LC_VAR_STRING, 38: &filename, 'f'); 39: 40: if (lc_rv_ret != 0) { 41: fprintf(stderr, "Error registering variable: %i.\\n", 42: lc_geterrno()); 43: return(EXIT_FAILURE); 44: } 45: 46: lc_p_ret = lc_process(argc, argv, "example", LC_CONF_APACHE, 47: NULL); 48: 49: lc_cleanup(); 50: 51: if (lc_p_ret != 0) { 52: fprintf(stderr, "Error processing configuration: \\ 53: %s\\n", lc_geterrstr()); 54: return(EXIT_FAILURE); 55: } 56: 57: if (filename != NULL) { 58: printf("File specified was: %s\\n", filename); 59: } else { 60: printf("No filename specified.\\n"); 61: } 62: 63: return(EXIT_SUCCESS); 64: } 65: .fi 66: 67: .SH "SEE ALSO" 68: .BR libconfig (3), 69: .BR lc_register_var (3), 70: .BR lc_register_callback (3), 71: .BR lc_geterrno (3), 72: .BR lc_geterrstr (3), 73: .BR lc_seterrstr (3), 74: .BR lc_handle_type (3), 75: .BR lc_process (3), 76: .BR lc_process_file (3) |