<commit_before>/*
 * buffer.c -- generic memory buffer .
 *
 * Copyright (c) 2001-2004, NLnet Labs. All rights reserved.
 *
 * See LICENSE for the license.
 *
 */

#include <config.h>

#include <stdio.h>

#include "buffer.h"

void
buffer_cleanup(void *arg)
{
	buffer_type *buffer = (buffer_type *) arg;
	assert(!buffer->_fixed);
	free(buffer->_data);
}

buffer_type *
buffer_create(region_type *region, size_t capacity)
{
	buffer_type *buffer = region_alloc(region, sizeof(buffer_type));
	if (!buffer)
		return NULL;
	
	buffer->_data = xalloc(capacity);
	buffer->_position = 0;
	buffer->_limit = buffer->_capacity = capacity;
	buffer->_fixed = 0;
	buffer_invariant(buffer);
	
	region_add_cleanup(region, buffer_cleanup, buffer);

	return buffer;
}

void<commit_msg>buffer.c: (buffer_cleanup) Is now static.<commit_after>/*
 * buffer.c -- generic memory buffer .
 *
 * Copyright (c) 2001-2004, NLnet Labs. All rights reserved.
 *
 * See LICENSE for the license.
 *
 */

#include <config.h>

#include <stdio.h>

#include "buffer.h"

static void
buffer_cleanup(void *arg)
{
	buffer_type *buffer = (buffer_type *) arg;
	assert(!buffer->_fixed);
	free(buffer->_data);
}

buffer_type *
buffer_create(region_type *region, size_t capacity)
{
	buffer_type *buffer = region_alloc(region, sizeof(buffer_type));
	if (!buffer)
		return NULL;
	
	buffer->_data = xalloc(capacity);
	buffer->_position = 0;
	buffer->_limit = buffer->_capacity = capacity;
	buffer->_fixed = 0;
	buffer_invariant(buffer);
	
	region_add_cleanup(region, buffer_cleanup, buffer);

	return buffer;
}

void
{'fraction_non_alphanumeric': 0.13993610223642172, 'fraction_numerical': 0.012779552715654952, 'mean_word_length': 4.633093525179856, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 21, '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': '6373738', 'n_tokens_mistral': 559, 'n_tokens_neox': 522, 'n_words': 128}