<commit_before>/* extendible vectors. <NAME> 2006.  Public domain. */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

#include "cext.h"

void
cext_vattach(Vector *v, void *p)
{
	++v->size;
	if (!(v->data = realloc(v->data, v->size * sizeof(void *)))) {
		fprintf(stderr, "%s\n", "Out of memory in cext_evector_attach\n");
		exit(1);
	}
	v->data[v->size - 1]=p;
}

void
cext_vdetach(Vector *v, void *data)
{
	unsigned int i;
	for(i = 0; i < v->size; i++)
		if (v->data[i] == data) {
			memmove(v->data + i, v->data + i + 1,
					(v->size - i - 1) * sizeof(void *));
			--v->size;
			return;
		}
	if(v->size == 0)
		free(v->data);
}
<commit_msg>thanks to usa, fixed the issues mentioned in IRC<commit_after>/* extendible vectors. <NAME> 2006.  Public domain. */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

#include "cext.h"

void
cext_vattach(Vector *v, void *p)
{
	++v->size;
	if (!(v->data = realloc(v->data, v->size * sizeof(void *)))) {
		fprintf(stderr, "%s\n", "Out of memory in cext_evector_attach\n");
		exit(1);
	}
	v->data[v->size - 1] = p;
}

void
cext_vdetach(Vector *v, void *data)
{
	unsigned int i;
	for(i = 0; i < v->size; i++)
		if (v->data[i] == data) {
			memmove(v->data + i, v->data + i + 1,
					(v->size - i - 1) * sizeof(void *));
			v->data[--v->size] = nil;
			break;
		}
	if(v->size == 0) {
		free(v->data);
		v->data = nil;
	}
}

{'fraction_non_alphanumeric': 0.22768798313422348, 'fraction_numerical': 0.014054813773717497, 'mean_word_length': 3.200589970501475, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 43, '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': '7082533', 'n_tokens_mistral': 682, 'n_tokens_neox': 628, 'n_words': 148}