<commit_before>#include "intern.h"
#include "hash.h"
#include "internal.h"

static Hash *symbol_table = NULL;


void intern_init()
{
    symbol_table = h_new_str(free, NULL);
    register_for_cleanup(symbol_table, (free_ft)&h_destroy);
}

const char *intern(const char *str)
{
    char *symbol = h_get(symbol_table, str);
    if (!symbol) {
        symbol = estrdup(str);
        h_set(symbol_table, symbol, symbol);
    }
    return symbol;
}

const char *intern_and_free(char *str)
{
    char *symbol = h_get(symbol_table, str);
    if (!symbol) {
        symbol = str;
        h_set(symbol_table, symbol, symbol);
    }
    else {
        free(str);
    }
    return symbol;
}<commit_msg>Added casts for compilation with C++<commit_after>#include "intern.h"
#include "hash.h"
#include "internal.h"

static Hash *symbol_table = NULL;


void intern_init()
{
    symbol_table = h_new_str(free, NULL);
    register_for_cleanup(symbol_table, (free_ft)&h_destroy);
}

const char *intern(const char *str)
{
    char *symbol = (char *)h_get(symbol_table, str);
    if (!symbol) {
        symbol = estrdup(str);
        h_set(symbol_table, symbol, symbol);
    }
    return symbol;
}

const char *intern_and_free(char *str)
{
    char *symbol = (char *)h_get(symbol_table, str);
    if (!symbol) {
        symbol = str;
        h_set(symbol_table, symbol, symbol);
    }
    else {
        free(str);
    }
    return symbol;
}
{'fraction_non_alphanumeric': 0.13370865587614356, 'fraction_numerical': 0.0, 'mean_word_length': 3.1578947368421053, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2827711', 'n_tokens_mistral': 504, 'n_tokens_neox': 499, 'n_words': 115}