<commit_before>#include "HalideRuntime.h"

#include <stdint.h>

#ifdef __APPLE__
typedef unsigned long size_t;
#else
#ifdef _LP64
typedef uint64_t size_t;
#else
typedef uint32_t size_t;
#endif
#endif
#define WEAK __attribute__((weak))
#ifndef NULL
#define NULL 0
#endif

extern "C" {

extern void *malloc(size_t);
extern void free(void *);

WEAK void *(*halide_custom_malloc)(size_t) = NULL;
WEAK void (*halide_custom_free)(void *) = NULL;
WEAK void halide_set_custom_allocator(void *(*cust_malloc)(size_t), void (*cust_free)(void *)) {
    halide_custom_malloc = cust_malloc;
    halide_custom_free = cust_free;
}

WEAK void *halide_malloc(size_t x) {
    if (halide_custom_malloc) {
        return halide_custom_malloc(x);
    } else {
        void *orig = malloc(x+32);
        if (orig == NULL) {
            // Will result in a failed assertion and a call to halide_error<commit_msg>Only define size_t if it hasn't already been defined.<commit_after>#include "HalideRuntime.h"

#include <stdint.h>

#ifndef _SIZE_T
#ifdef __APPLE__
typedef unsigned long size_t;
#else
#ifdef _LP64
typedef uint64_t size_t;
#else
typedef uint32_t size_t;
#endif
#endif
#endif

#define WEAK __attribute__((weak))
#ifndef NULL
#define NULL 0
#endif


extern "C" {

extern void *malloc(size_t);
extern void free(void *);

WEAK void *(*halide_custom_malloc)(size_t) = NULL;
WEAK void (*halide_custom_free)(void *) = NULL;
WEAK void halide_set_custom_allocator(void *(*cust_malloc)(size_t), void (*cust_free)(void *)) {
    halide_custom_malloc = cust_malloc;
    halide_custom_free = cust_free;
}

WEAK void *halide_malloc(size_t x) {
    if (halide_custom_malloc) {
        return halide_custom_malloc(x);
    } else {
        void *orig = malloc(x+32);
        if (orig == NULL) {
            // Will result in a failed assertion and a call to halide_error
{'fraction_non_alphanumeric': 0.11189570885388377, 'fraction_numerical': 0.00977729494839761, 'mean_word_length': 4.433628318584071, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4489494', 'n_tokens_mistral': 691, 'n_tokens_neox': 654, 'n_words': 176}