<commit_before>#include <stdarg.h>
#include <string.h>

#include "lily_raiser.h"

#include "lily_api_alloc.h"

/* If the error raised is a code (and not a proper error), then this is used to
   get a name for the error. */
static const char *lily_error_names[] =
    {"Error", "SyntaxError", "DivisionByZeroError", "IndexError",
     "ValueError", "RuntimeError", "KeyError", "FormatError", "IOError"};

lily_raiser *lily_new_raiser(void)
{
    lily_raiser *raiser = lily_malloc(sizeof(lily_raiser));
    lily_jump_link *first_jump = malloc(sizeof(lily_jump_link));
    first_jump->prev = NULL;
    first_jump->next = NULL;

    raiser->msgbuf = lily_new_msgbuf();
    raiser->all_jumps = first_jump;
    raiser->line_adjust = 0;
    raiser->exception_cls = NULL;

    return raiser;
}

void lily_free_raiser(lily_raiser *raiser)
{
    if (raiser->msgbuf)
        lily_free_msgbuf(raiser->msgbuf);

    lily_jump_link *jump_next;
    while (raiser->all_jumps->prev)
        raiser->all_jumps = raiser->all_jumps->prev;

    while (raiser->all_jumps) {
        jump_next = raiser->all_jumps->next;
        lily_free(raiser->all_jumps);
        raiser->all_jumps = jump_next;
    }

    lily_free(raiser);
}

/* This ensures that there is space for a jump for the caller. It will first try
   to reuse a jump, then to allocate a new one. */
lily_jump_link *lily_jump_setup(lily_raiser *raiser)
{
    if (raiser->all_jumps->next)
        raiser->all_jumps = raiser->all_jumps->next;
    else {
        lily_jump_link *new_link = lily_malloc(sizeof(lily_jump_link));
        new_link->prev = raiser->all_jumps;
        raiser->all_jumps->next = new_link;

        new_link->next = NULL;

        raiser->all_jumps = new_link;
    }

    return raiser->all_jumps;
}

/* Releases the jump provided by lily_jump_setup. */
void lily_release_jump(lily_raiser *raiser)
{<commit_msg>raiser: The msgbuf never fails to alloc, so remove that check.<commit_after>#include <stdarg.h>
#include <string.h>

#include "lily_raiser.h"

#include "lily_api_alloc.h"

/* If the error raised is a code (and not a proper error), then this is used to
   get a name for the error. */
static const char *lily_error_names[] =
    {"Error", "SyntaxError", "DivisionByZeroError", "IndexError",
     "ValueError", "RuntimeError", "KeyError", "FormatError", "IOError"};

lily_raiser *lily_new_raiser(void)
{
    lily_raiser *raiser = lily_malloc(sizeof(lily_raiser));
    lily_jump_link *first_jump = malloc(sizeof(lily_jump_link));
    first_jump->prev = NULL;
    first_jump->next = NULL;

    raiser->msgbuf = lily_new_msgbuf();
    raiser->all_jumps = first_jump;
    raiser->line_adjust = 0;
    raiser->exception_cls = NULL;

    return raiser;
}

void lily_free_raiser(lily_raiser *raiser)
{
    lily_jump_link *jump_next;
    while (raiser->all_jumps->prev)
        raiser->all_jumps = raiser->all_jumps->prev;

    while (raiser->all_jumps) {
        jump_next = raiser->all_jumps->next;
        lily_free(raiser->all_jumps);
        raiser->all_jumps = jump_next;
    }

    lily_free_msgbuf(raiser->msgbuf);
    lily_free(raiser);
}

/* This ensures that there is space for a jump for the caller. It will first try
   to reuse a jump, then to allocate a new one. */
lily_jump_link *lily_jump_setup(lily_raiser *raiser)
{
    if (raiser->all_jumps->next)
        raiser->all_jumps = raiser->all_jumps->next;
    else {
        lily_jump_link *new_link = lily_malloc(sizeof(lily_jump_link));
        new_link->prev = raiser->all_jumps;
        raiser->all_jumps->next = new_link;

        new_link->next = NULL;

        raiser->all_jumps = new_link;
    }

    return raiser->all_jumps;
}

/* Releases the jump provided by lily_jump_setup. */
void lily_release_jump(lily_raiser *raiser)
{
{'fraction_non_alphanumeric': 0.12088204038257173, 'fraction_numerical': 0.0005313496280552603, 'mean_word_length': 3.5471014492753623, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 66, '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': '3577855', 'n_tokens_mistral': 1436, 'n_tokens_neox': 1324, 'n_words': 292}