<commit_before>#include <libopticon/datatypes.h>
#include <unistd.h>
#include <stdlib.h>

void watchlist_init (watchlist *self) {
    self->first = self->last = NULL;
    pthread_mutex_init (&self->mutex, NULL);
}

void watchlist_add (watchlist *self, meterwatch *m) {
    if (self->last) {
        m->prev = self->last;
        self->last->next = m;
        self->last = m;
    }
    else {
        self->first = self->last = m;
    }
}

void watchlist_add_uint (watchlist *self, meterid_t id, watchtype tp,
                         uint64_t val, double bad, watchtrigger trig) {
    meterwatch *w = (meterwatch *) malloc (sizeof (meterwatch));
    w-> next = w->prev = NULL;
    w->id = id;
    w->tp = tp;
    w->trigger = trig;
    w->badness = bad;
    w->dat.u64 = val;
    watchlist_add (self, w);
}

void watchlist_add_frac (watchlist *self, meterid_t id, watchtype tp,
                         double val, double bad, watchtrigger trig) {
    meterwatch *w = (meterwatch *) malloc (sizeof (meterwatch));
    w-> next = w->prev = NULL;
    w->id = id;
    w->tp = tp;
    w->trigger = trig;
    w->badness = bad;
    w->dat.frac = val;
    watchlist_add (self, w);
}

void watchlist_add_str (watchlist *self, meterid_t id, watchtype tp,
                        const char *val, double bad, watchtrigger trig) {
                        
    meterwatch *w = (meterwatch *) malloc (sizeof (meterwatch));
    w-> next = w->prev = NULL;
    w->id = id;
    w->tp = tp;
    w->trigger = trig;
    w->badness = bad;
    strncpy (w->dat.str.str, val, 127);
    w->dat.str.str[127] = 0;
    watchlist_add (self, w);
}

void watchlist_clear (watchlist *self) {
    meterwatch *w;
    meterwatch *nw;
    w = self->first;
    while (w) {
        nw = w->next;
        free (w);
        w = nw;
    }
}
<commit_msg>Clear relevant pointers, this stops a SIGHUP from wreaking havoc on the next wachter round<commit_after>#include <libopticon/datatypes.h>
#include <unistd.h>
#include <stdlib.h>

void watchlist_init (watchlist *self) {
    self->first = self->last = NULL;
    pthread_mutex_init (&self->mutex, NULL);
}

void watchlist_add (watchlist *self, meterwatch *m) {
    if (self->last) {
        m->prev = self->last;
        self->last->next = m;
        self->last = m;
    }
    else {
        self->first = self->last = m;
    }
}

void watchlist_add_uint (watchlist *self, meterid_t id, watchtype tp,
                         uint64_t val, double bad, watchtrigger trig) {
    meterwatch *w = (meterwatch *) malloc (sizeof (meterwatch));
    w-> next = w->prev = NULL;
    w->id = id;
    w->tp = tp;
    w->trigger = trig;
    w->badness = bad;
    w->dat.u64 = val;
    watchlist_add (self, w);
}

void watchlist_add_frac (watchlist *self, meterid_t id, watchtype tp,
                         double val, double bad, watchtrigger trig) {
    meterwatch *w = (meterwatch *) malloc (sizeof (meterwatch));
    w-> next = w->prev = NULL;
    w->id = id;
    w->tp = tp;
    w->trigger = trig;
    w->badness = bad;
    w->dat.frac = val;
    watchlist_add (self, w);
}

void watchlist_add_str (watchlist *self, meterid_t id, watchtype tp,
                        const char *val, double bad, watchtrigger trig) {
                        
    meterwatch *w = (meterwatch *) malloc (sizeof (meterwatch));
    w-> next = w->prev = NULL;
    w->id = id;
    w->tp = tp;
    w->trigger = trig;
    w->badness = bad;
    strncpy (w->dat.str.str, val, 127);
    w->dat.str.str[127] = 0;
    watchlist_add (self, w);
}

void watchlist_clear (watchlist *self) {
    meterwatch *w;
    meterwatch *nw;
    w = self->first;
    while (w) {
        nw = w->next;
        free (w);
        w = nw;
    }
    self->first = self->last = NULL;
}

{'fraction_non_alphanumeric': 0.145610278372591, 'fraction_numerical': 0.005888650963597431, 'mean_word_length': 2.188566552901024, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 81, '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': '2236925', 'n_tokens_mistral': 1366, 'n_tokens_neox': 1317, 'n_words': 353}