<commit_before>
	/* (c) 2007-2012 <NAME>, modified slightly for pinba2 by <NAME> */

#ifndef PINBA__MISC_ARRAY_H
#define PINBA__MISC_ARRAY_H 1

#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>

#ifdef __cplusplus
#define __builtin_types_compatible_p(a,b) 1 /* this builtin is unavailable in C++ mode */
#endif

void unexpected_at_compile_time()
#if defined(__GNUC__) && !defined(__clang__ /* almost a gnuc but some bits still missing */)
	 __attribute__((error("unexpected at compile time")))
#endif
;

struct array_s {
	void *data;
	size_t sz;
	unsigned long used;
	unsigned long allocated;
};

typedef struct array_s array_t;

#define array_init array_init0

#define array_v(a, type) ({ \
	if (!__builtin_types_compatible_p(__typeof__(a), struct array_s *) && \
		!__builtin_types_compatible_p(__typeof__(a), const struct array_s *)) { \
		unexpected_at_compile_time(); \
	} \
	((type *) (a)->data); })

#define array_init_static(a) (struct array_s) { .data = a, .sz = sizeof(a[0]), .allocated = sizeof(a) / sizeof(a[0]) }

#define array_push_v(a, type) ({ \
	if (!__builtin_types_compatible_p(__typeof__(a), struct array_s *)) { \
		unexpected_at_compile_time(); \
	} \
	((type *) array_push(a)); })

static inline int array_shrink_with_ratio(struct array_s *a, float ratio);
static inline int array_reserve_with_ratio(struct array_s *a, unsigned long count, float ratio);

static inline struct array_s *array_init0(struct array_s *a, size_t sz, unsigned long initial_num)
{
	void *allocated = 0;

	if (!a) {
		a = (struct array_s *) malloc(sizeof(struct array_s));

		if (!a) {
			return 0;
		}

		allocated = a;
	}

	a->sz = sz;

	if (initial_num) {
		a->data = calloc(sz, initial_num);
<commit_msg>use malloc instead of callor for array_init, there is no need to zerofill<commit_after>
	/* (c) 2007-2012 <NAME>, modified slightly for pinba2 by <NAME> */

#ifndef PINBA__MISC_ARRAY_H
#define PINBA__MISC_ARRAY_H 1

#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>

#ifdef __cplusplus
#define __builtin_types_compatible_p(a,b) 1 /* this builtin is unavailable in C++ mode */
#endif

void unexpected_at_compile_time()
#if defined(__GNUC__) && !defined(__clang__ /* almost a gnuc but some bits still missing */)
	 __attribute__((error("unexpected at compile time")))
#endif
;

struct array_s {
	void *data;
	size_t sz;
	unsigned long used;
	unsigned long allocated;
};

typedef struct array_s array_t;

#define array_init array_init0

#define array_v(a, type) ({ \
	if (!__builtin_types_compatible_p(__typeof__(a), struct array_s *) && \
		!__builtin_types_compatible_p(__typeof__(a), const struct array_s *)) { \
		unexpected_at_compile_time(); \
	} \
	((type *) (a)->data); })

#define array_init_static(a) (struct array_s) { .data = a, .sz = sizeof(a[0]), .allocated = sizeof(a) / sizeof(a[0]) }

#define array_push_v(a, type) ({ \
	if (!__builtin_types_compatible_p(__typeof__(a), struct array_s *)) { \
		unexpected_at_compile_time(); \
	} \
	((type *) array_push(a)); })

static inline int array_shrink_with_ratio(struct array_s *a, float ratio);
static inline int array_reserve_with_ratio(struct array_s *a, unsigned long count, float ratio);

static inline struct array_s *array_init0(struct array_s *a, size_t sz, unsigned long initial_num)
{
	void *allocated = 0;

	if (!a) {
		a = (struct array_s *) malloc(sizeof(struct array_s));

		if (!a) {
			return 0;
		}

		allocated = a;
	}

	a->sz = sz;

	if (initial_num) {
		/*
		don't calloc, there is no need to zerofill

		a->data = calloc(sz, initial_num);
		*/

		a->data = malloc(sz, initial_num);

{'fraction_non_alphanumeric': 0.13741721854304637, 'fraction_numerical': 0.009381898454746136, 'mean_word_length': 4.772292993630574, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 22, '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': '3265279', 'n_tokens_mistral': 1401, 'n_tokens_neox': 1321, 'n_words': 347}