From 60f0166e8eae843b94963a2cbb2de08e9d397b69 Mon Sep 17 00:00:00 2001 From: "Anderson Felippe (BISB/ENG)" Date: Tue, 14 Jan 2020 13:27:26 -0300 Subject: [PATCH] Add compatibility with g++ compiler and C++11 standard It's not possible to use malloc without a cast as it treats it as an invalid conversion. Initializing a char pointer with an empty string will also issue a warning, so current_section char pointer must not be initialized. --- src/ini.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ini.c b/src/ini.c index ab5f11d..4cb5c2f 100644 --- a/src/ini.c +++ b/src/ini.c @@ -179,7 +179,7 @@ ini_t* ini_load(const char *filename) { int n, sz; /* Init ini struct */ - ini = malloc(sizeof(*ini)); + ini = (ini_t*)malloc(sizeof(*ini)); if (!ini) { goto fail; } @@ -197,7 +197,7 @@ ini_t* ini_load(const char *filename) { rewind(fp); /* Load file content into memory, null terminate, init end var */ - ini->data = malloc(sz + 1); + ini->data = (char*)malloc(sz + 1); ini->data[sz] = '\0'; ini->end = ini->data + sz; n = fread(ini->data, 1, sz, fp); @@ -226,7 +226,7 @@ void ini_free(ini_t *ini) { const char* ini_get(ini_t *ini, const char *section, const char *key) { - char *current_section = ""; + char *current_section; char *val; char *p = ini->data;