<commit_before>/* arena.c
 * A simple arena allocator
 *
 * Written by <NAME> (<EMAIL>)
 *
 * This code is in the public domain, see
 * UNLICENSE for details
 */
#include <stdlib.h>

#include "arena.h"

#define BLOB_MIN 4096
#define CHUNK_SIZE 16384
#define ALIGNMENT 4

struct chunk {
    struct chunk *next;
    void *mem;
    void *current;
    int size;
};

struct blob {
    struct blob *next;
};

struct arena {
    struct chunk *chunks;
    struct blob *blobs;
};

ahandle arena_create(void) 
{
    ahandle a = malloc(sizeof(struct arena));
    a->chunks = NULL;
    a->blobs = NULL;
}

static void create_chunk(ahandle a) 
{
    struct chunk *new_chunk = malloc(sizeof(struct chunk));
    new_chunk->mem = malloc(CHUNK_SIZE);
    new_chunk->current = new_chunk->mem;
    new_chunk->size = CHUNK_SIZE;
    new_chunk->next = a->chunks;
    a->chunks = new_chunk;
}

void *arena_alloc(ahandle a, size_t s) 
{
    void *mem;
    if(s < BLOB_MIN) {
        /* Allocate in a chunk */
        size_t step = s>4?s:4;
        step += ALIGNMENT - (step % ALIGNMENT);
        if(a->chunks == NULL || a->chunks->size < step) {
            create_chunk(a);
        }
        mem = a->chunks->current;
        a->chunks->current+=step;<commit_msg>Delete pointless (and potentially buggy) ssignment.<commit_after>/* arena.c
 * A simple arena allocator
 *
 * Written by <NAME> (<EMAIL>)
 *
 * This code is in the public domain, see
 * UNLICENSE for details
 */
#include <stdlib.h>

#include "arena.h"

#define BLOB_MIN 4096
#define CHUNK_SIZE 16384
#define ALIGNMENT 4

struct chunk {
    struct chunk *next;
    void *mem;
    void *current;
    int size;
};

struct blob {
    struct blob *next;
};

struct arena {
    struct chunk *chunks;
    struct blob *blobs;
};

ahandle arena_create(void) 
{
    ahandle a = malloc(sizeof(struct arena));
    a->chunks = NULL;
    a->blobs = NULL;
}

static void create_chunk(ahandle a) 
{
    struct chunk *new_chunk = malloc(sizeof(struct chunk));
    new_chunk->mem = malloc(CHUNK_SIZE);
    new_chunk->current = new_chunk->mem;
    new_chunk->size = CHUNK_SIZE;
    new_chunk->next = a->chunks;
    a->chunks = new_chunk;
}

void *arena_alloc(ahandle a, size_t s) 
{
    void *mem;
    if(s < BLOB_MIN) {
        /* Allocate in a chunk */
        size_t step;
        step += ALIGNMENT - (step % ALIGNMENT);
        if(a->chunks == NULL || a->chunks->size < step) {
            create_chunk(a);
        }
        mem = a->chunks->current;
        a->chunks->current+=step;
{'fraction_non_alphanumeric': 0.13266932270916335, 'fraction_numerical': 0.008764940239043825, 'mean_word_length': 2.6980854197349045, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 42, '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': '6209460', 'n_tokens_mistral': 921, 'n_tokens_neox': 902, 'n_words': 233}