ECONF_FREEP(3)

NAME
econf_freeFilep - Free memory allocated by e.g. econf_readConfig.
econf_freeArrayp - Free an array of strings created by econf_getGroups() or econf_getKeys().

SYNOPSIS

#include <libeconf.h>

void econf_freeFileP(econf_file **key_file);
void econf_freeArrayP(char ***array);

DESCRIPTION

The econf_freeFileP() function releases the memory allocated for the configuration file object specified by key_file.

The econf_freeArrayP() function is used to release the memory allocated for an array of strings, returned by a successful call to econf_getGroups(3) and econf_getKeys(3).

Despite econf_freeFile() / econf_freeArray() these functions are called by using __attribute__ in the declaration (Have a look to the example). So, no addition free is needed for releasing the memory.

RETURN VALUE

The functions return nothing (void).

ERRORS

These functions do not return an error code.

EXAMPLE

    #include <libeconf.h>
    #include <stdio.h>
    int main(void) {
        __attribute__((cleanup(econf_freeFilep))) econf_file *conf = NULL;

        econf_err err;
        /*
         * Reading
         */
        err = econf_readConfig(&conf,
                               "foo",                 /* project name */
                               "/usr/lib",            /* vendor directory */
                               "example",             /* config name */
                               "conf",                /* suffix */
                               "=",                   /* delimiter */
                               "#");                  /* comment */
        if (err != ECONF_SUCCESS) {
            fprintf(stderr, "Failed to read config: %d\n", err);
            return 1;
        }
        __attribute__((cleanup(econf_freeArrayp))) char **groups;
        size_t group_number;
        if ((err = econf_getGroups(conf, &group_number, &groups)))
        {
            fprintf (stderr, "Error getting all groups: %s, econf_errString(err));
            return 1;
        }
        __attribute__((cleanup(econf_freeArrayp))) char **keys;
        size_t key_number;
        error = econf_getKeys (key_file, "Group1", &key_number, &keys);
        if (error)
        {
            fprintf (stderr, "Error getting all keys for [%s]: %s,
                     "Group1", econf_errString(err));
            return 1;
        }
        /* No econf_free() or econf_freeArray() call is needed. */
        return 0;
    }

SEE ALSO

econf_getGroups(3), econf_getKeys(3), econf_freeArray(3), libeconf(3)