<commit_before>

// This file contains definition of C++ new/delete operators


#include <stddef.h>
#include <malloc.h>
#include "stdexcept.h"

__attribute__((weak))
void * operator new(size_t size) {
    void * mem = malloc(size);
    if(mem == NULL) {
        throw std::bad_alloc();
    }

    return mem;
}


__attribute__((weak))
void operator delete(void * ptr) {
    free(ptr);
}


__attribute__((weak))
void * operator new[](size_t size) {
    return ::operator new(size);
}


__attribute__((weak))
void operator delete[](void * ptr) {
    ::operator delete(ptr);
}


<commit_msg>am a0513e59: set_new_handler was implemented<commit_after>

// This file contains definition of C++ new/delete operators


#include <stddef.h>
#include <malloc.h>
#include "stdexcept.h"

namespace std {
    void terminate();
}

typedef void (*new_handler)();
static new_handler new_handl = &std::terminate;


namespace std {
    new_handler set_new_handler(new_handler handl) {
        new_handler old = new_handl;
        new_handl = handl;
        return old;
    }
}


__attribute__((weak))
void * operator new(size_t size) {

    void * mem = malloc(size);
    while(mem == NULL) {
        new_handl();
        mem = malloc(size);
    }

    return mem;
}


__attribute__((weak))
void operator delete(void * ptr) {
    free(ptr);
}


__attribute__((weak))
void * operator new[](size_t size) {
    return ::operator new(size);
}


__attribute__((weak))
void operator delete[](void * ptr) {
    ::operator delete(ptr);
}



{'fraction_non_alphanumeric': 0.13879709187045605, 'fraction_numerical': 0.0039656311962987445, 'mean_word_length': 3.5194029850746267, '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': '2916763', 'n_tokens_mistral': 531, 'n_tokens_neox': 505, 'n_words': 128}