~ecs/ini

dceda55a3ede8335b78f3517b6af0902076875e3 — Eyal Sawady 1 year, 4 months ago 3893878
free() arrays on exit
1 files changed, 10 insertions(+), 0 deletions(-)

M frontend.c
M frontend.c => frontend.c +10 -0
@@ 29,6 29,14 @@ struct array {
	char **sections;
};

static void deinit_array(struct array arr)
{
	for (int i = 0; i < arr.size; i++) {
		free(arr.sections[i]);
	}
	free(arr.sections);
}

static int section_list_handler(void *user, const char *section,
		const char *key, const char *value)
{


@@ 118,9 126,11 @@ int main(int argc, char **argv)
		sections.sections = malloc(8 * sizeof(char *));

		if (ini_parse(argv[1], section_list_handler, &sections) < 0) {
			deinit_array(sections);
			printf("Cant load '%s'\n", argv[1]);
			return 2;
		}
		deinit_array(sections);
	} else if (argc == 3) {
		if (ini_parse(argv[1], key_list_handler, argv[2]) < 0) {
			printf("Cant load '%s'\n", argv[1]);