<commit_before>#ifndef _lib_arr_h_
#define _lib_arr_h_
#include <stdlib.h>
#include <string.h>

static inline
void *
arr_alloc(size_t size, size_t len)
{
	size_t mem; 
	mem = size * len + sizeof (size_t);
	return (size_t*)calloc(1, mem) + 1;
}

static inline
void
arr_free(void *a)
{
	free((size_t *)a - 1);
}

static inline
size_t
arr_len(void const *a)
{
	size_t ret;
	memcpy(&ret, (size_t *)a - 1, sizeof ret);
	return ret;
}

static inline
void
arr_cat(void *d, void const *s, size_t size)
{
	memcpy((char*)d + arr_len(d) * size, s, size * arr_len(s));
	memcpy((size_t*)d - 1,
	       (size_t[]){arr_len(d) + arr_len(s)},
	       sizeof (size_t));
}


static inline
void
arr_get(void *dst, void *src, size_t size)
{
	memcpy(dst,(char *)src+(arr_len(src)-1)*size, size);
	memset((char*)src+(arr_len(src)-1)*size, 0, size);
	memcpy((char*)src - sizeof (size_t),
	       (size_t[]){arr_len(src)-1},
	       sizeof (size_t));
}

static inline
void
arr_put(void *dst, void const *src, size_t size)
{
	memcpy((char *)dst + arr_len(dst) * size, src, size);
	memcpy((char *)dst - sizeof (size_t),
	       (size_t[]){arr_len(dst)+1},
	       sizeof (size_t));
}

static inline
void
arr_zero(void *arr, size_t size)
{
	memset((size_t*)arr-1,
	       0,
	       sizeof(size_t)+(arr_len(arr)-1)*size);
}

#define arr_cat(d, s) arr_cat(d, s, sizeof *d)
#define arr_get(d, s) arr_get(d, s, sizeof *s)
#define arr_put(d, s) arr_put(d, s, sizeof *d)
#define arr_zero(a)   arr_zero(a, sizeof *a)
#endif /* _lib_arr_h_ */
<commit_msg>[arr] remove two unused functions, add two more<commit_after>#ifndef _lib_arr_h_
#define _lib_arr_h_
#include <stdlib.h>
#include <string.h>

static inline
void *
arr_alloc(size_t size, size_t len)
{
	size_t mem; 
	mem = size * len + sizeof (size_t);
	return (size_t*)calloc(1, mem) + 1;
}

static inline
void
arr_free(void *a)
{
	free((size_t *)a - 1);
}

static inline
size_t
arr_len(void const *a)
{
	size_t ret;
	memcpy(&ret, (size_t *)a - 1, sizeof ret);
	return ret;
}

static inline
void *
arr_peek(void const *a, size_t size)
{
	return (char *)a + (arr_len(a) - 1) * size;
}

static inline
void
arr_get(void *dst, void *src, size_t size)
{
	memcpy(dst,(char *)src+(arr_len(src)-1)*size, size);
	memset((char*)src+(arr_len(src)-1)*size, 0, size);
	memcpy((char*)src - sizeof (size_t),
	       (size_t[]){arr_len(src)-1},
	       sizeof (size_t));
}

static inline
void
arr_put(void *dst, void const *src, size_t size)
{
	memcpy((char *)dst + arr_len(dst) * size, src, size);
	memcpy((char *)dst - sizeof (size_t),
	       (size_t[]){arr_len(dst)+1},
	       sizeof (size_t));
}

static inline
void
arr_rm(void *a, size_t w, size_t z)
{
	memmove((char*)a+w*z, (char*)a+w*z+z, arr_len(a)-w-1);
	memcpy((size_t*)a-1, (size_t[]){arr_len(a)-1},sizeof (size_t));
}

#define arr_cat(d, s) arr_cat(d, s, sizeof *d)
#define arr_get(d, s) arr_get(d, s, sizeof *s)
#define arr_put(d, s) arr_put(d, s, sizeof *d)
#define arr_peek(a)   arr_peek(a, sizeof *a)
#define arr_rm(a, w)  arr_rm(a, w, sizeof *a)
#endif /* _lib_arr_h_ */

{'fraction_non_alphanumeric': 0.18199737187910645, 'fraction_numerical': 0.008541392904073587, 'mean_word_length': 4.408525754884547, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '2776804', 'n_tokens_mistral': 1347, 'n_tokens_neox': 1320, 'n_words': 319}