Check-in [cb9ab48b6d]
Overview
Comment:Updated test driver to be completely leak-free
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: cb9ab48b6d415bdef0e4282572f37205580d76a4
User & Date: rkeene on 2014-11-25 18:04:13
Other Links: manifest | tags
Context
2014-11-25
18:10
libconfig 0.3.3 check-in: 365b6c155e user: rkeene tags: trunk, 0.3.3
18:04
Updated test driver to be completely leak-free check-in: cb9ab48b6d user: rkeene tags: trunk
18:03
Updated to deal with erroptname more completely check-in: ba3430c2d6 user: rkeene tags: trunk
Changes

Modified test-lc.c from [039acf4416] to [9b3354fc6a].

    47     47   	lc_register_var("ipaddr", LC_VAR_IP, &ipaddr, 'i');
    48     48   	lc_register_callback("sally", 0, LC_VAR_STRING, sally_cmd, NULL);
    49     49   	lc_register_callback("HELP", 'h', LC_VAR_NONE, help_cmd, NULL);
    50     50   	lc_register_callback("*.ifmodule", 0, LC_VAR_NONE, cmd_ifmodule, NULL);
    51     51   	lcpret = lc_process_file("testapp", "test.conf", LC_CONF_APACHE);
    52     52   	if (lcpret < 0) {
    53     53   		fprintf(stderr, "Error processing config file: %s\n", lc_geterrstr());
           54  +
           55  +		if (joeval != NULL) {
           56  +			free(joeval);
           57  +		}
           58  +
           59  +		lc_cleanup();
           60  +
    54     61   		return(EXIT_FAILURE);
    55     62   	}
    56     63   
    57     64   	lcpret = lc_process(argc, argv, "testapp", LC_CONF_APACHE, "test.cfg");
    58     65   	if (lcpret < 0) {
    59     66   		fprintf(stderr, "Error processing config file: %s\n", lc_geterrstr());
           67  +
           68  +		if (joeval != NULL) {
           69  +			free(joeval);
           70  +		}
           71  +
           72  +		lc_cleanup();
           73  +
    60     74   		return(EXIT_FAILURE);
    61     75   	}
    62     76   
    63     77   	lc_cleanup();
    64     78   
    65     79   	if (joeval != NULL) {
    66     80   		fprintf(stderr, "joeval = \"%s\"\n", joeval);
           81  +
           82  +		free(joeval);
    67     83   	} else {
    68     84   		fprintf(stderr, "joeval = \"(null)\"\n");
    69     85   	}
    70     86   	fprintf(stderr, "xval = %llu\n", (unsigned long long) xval);
    71     87   	fprintf(stderr, "onoff = %i\n", onoff);
    72     88   	fprintf(stderr, "long = %i\n", onoff2);
    73     89   	fprintf(stderr, "ip = %08lx\n", (unsigned long) ipaddr);
    74     90   	for (i = lc_optind; i < argc; i++) {
    75     91   		fprintf(stderr, "argv[%i] = \"%s\"\n", i, argv[i]);
    76     92   	}
    77     93   
    78     94   	return(0);
    79     95   }