<commit_before>/* See LICENSE file for copyright and license details. */
#include <assert.h>
#include <stdlib.h>
#include <string.h>

#include "list.h"

struct list {
	size_t length;
	size_t allocated_items;
	void **items;
};

list_t *list_new(size_t initial_size)
{
	list_t *list;

	list = calloc(1, sizeof(list_t));
	list->allocated_items = initial_size;
	if(list->allocated_items == 0)
		list->allocated_items = 8;
	list->items = calloc(list->allocated_items, sizeof(void *));

	return list;
}

void list_free(const list_t *list, list_item_deallocator deallocator)
{
	if(list == NULL)
		return;
	if(deallocator)
		for(size_t i = 0; i < list->length; i++)
			deallocator(list->items[i]);
	free(list->items);
	free((void *)list);
}

size_t list_length(const list_t *list)
{
	return list->length;
}

static void list_make_room(list_t *list)
{
	list->allocated_items *= 2;
	list->items = realloc(list->items, list->allocated_items * sizeof(void *));
}<commit_msg>list: use malloc instead of calloc in list_new<commit_after>/* See LICENSE file for copyright and license details. */
#include <assert.h>
#include <stdlib.h>
#include <string.h>

#include "list.h"

struct list {
	size_t length;
	size_t allocated_items;
	void **items;
};

list_t *list_new(size_t initial_size)
{
	list_t *list;

	list = malloc(sizeof(list_t));
	list->allocated_items = initial_size;
	if(list->allocated_items == 0)
		list->allocated_items = 8;
	list->items = malloc(list->allocated_items * sizeof(void *));
	list->length = 0;

	return list;
}

void list_free(const list_t *list, list_item_deallocator deallocator)
{
	if(list == NULL)
		return;
	if(deallocator)
		for(size_t i = 0; i < list->length; i++)
			deallocator(list->items[i]);
	free(list->items);
	free((void *)list);
}

size_t list_length(const list_t *list)
{
	return list->length;
}

static void list_make_room(list_t *list)
{
	list->allocated_items *= 2;
	list->items = realloc(list->items, list->allocated_items * sizeof(void *));
}
{'fraction_non_alphanumeric': 0.15096251266464034, 'fraction_numerical': 0.005065856129685917, 'mean_word_length': 5.076923076923077, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 36, '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': '4346028', 'n_tokens_mistral': 778, 'n_tokens_neox': 748, 'n_words': 168}