<commit_before>#include "conf.h"
#include "json.h"

#include <sys/stat.h>
#include <sys/mman.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <fcntl.h>



JSON_BEGIN( cfg_host )
    JSON_STRING( cfg_host, hostname ),
    JSON_STRING( cfg_host, restdir ),
    JSON_STRING( cfg_host, datadir ),
    JSON_STRING( cfg_host, index ),
    JSON_STRING( cfg_host, zip )
JSON_END( cfg_host );

JSON_BEGIN( cfg_server )
    JSON_INT( cfg_server, port ),
    JSON_STRING( cfg_server, ipv4 ),
    JSON_STRING( cfg_server, ipv6 ),
    JSON_STRING( cfg_server, unix ),
    JSON_ARRAY( cfg_server, hosts, cfg_host )
JSON_END( cfg_server );



static cfg_server* servers = NULL;
static size_t num_servers = 0;

static char* conf_buffer;
static size_t conf_size;


static int config_post_process( void )
{
    cfg_host* host;
    size_t i, j;

    for( i=0; i<num_servers; ++i )
    {
        for( j=0; j<servers[ i ].num_hosts; ++j )
        {
            host = servers[ i ].hosts + j;
            if( host->datadir && *host->datadir )
            {
                host->datadir = realpath( host->datadir, NULL );
                if( !host->datadir )
                    return 0;
            }
            if( host->zip && *host->zip )
            {
                host->zip = realpath( host->zip, NULL );
                if( !host->zip )<commit_msg>Fix free of static data<commit_after>#include "conf.h"
#include "json.h"

#include <sys/stat.h>
#include <sys/mman.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <fcntl.h>



JSON_BEGIN( cfg_host )
    JSON_STRING( cfg_host, hostname ),
    JSON_STRING( cfg_host, restdir ),
    JSON_STRING( cfg_host, datadir ),
    JSON_STRING( cfg_host, index ),
    JSON_STRING( cfg_host, zip )
JSON_END( cfg_host );

JSON_BEGIN( cfg_server )
    JSON_INT( cfg_server, port ),
    JSON_STRING( cfg_server, ipv4 ),
    JSON_STRING( cfg_server, ipv6 ),
    JSON_STRING( cfg_server, unix ),
    JSON_ARRAY( cfg_server, hosts, cfg_host )
JSON_END( cfg_server );



static cfg_server* servers = NULL;
static size_t num_servers = 0;

static char* conf_buffer;
static size_t conf_size;


static int config_post_process( void )
{
    cfg_host* host;
    size_t i, j;

    for( i=0; i<num_servers; ++i )
    {
        for( j=0; j<servers[ i ].num_hosts; ++j )
        {
            host = servers[ i ].hosts + j;
            if( host->datadir && !host->datadir[0] )
                host->datadir = NULL;
            if( host->zip && !host->zip[0] )
                host->zip = NULL;

            if( host->datadir )
            {
                host->datadir = realpath( host->datadir, NULL );
                if( !host->datadir )
                    return 0;
            }
            if( host->zip )
            {
                host->zip = realpath( host->zip, NULL );
                if( !host->zip )
{'fraction_non_alphanumeric': 0.13292641573414718, 'fraction_numerical': 0.004747371990505256, 'mean_word_length': 2.2346491228070176, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '147544', 'n_tokens_mistral': 1078, 'n_tokens_neox': 1042, 'n_words': 246}