<commit_before>#include "ire.h"


IRE_API(ire_error_t)
ire_code_create(uint16_t base, uint16_t entry, uint16_t stack_base,
                uint16_t interrupt_base, uint16_t interrupt_size,
                uint16_t *interrupt_table, uint16_t size, uint8_t *data,
                ire_code_t **destination) {
    ire_code_t *self;

    if ((interrupt_size > 0 && interrupt_table == NULL) || (size > 0 && data == NULL) || destination == NULL) {
        return IRE_ERROR_NULL_POINTER;
    }

    self = malloc(sizeof(*self) + size);

    if (self == NULL) {
        return IRE_ERROR_OUT_OF_MEMORY;
    }

    self->base = base;
    self->entry = entry;
    self->stack_base = stack_base;
    self->interrupt_base = interrupt_base;
    self->size = size;

    memset(self->interrupt_table, 0, sizeof(self->interrupt_table));
    memcpy(self->interrupt_table, interrupt_table, interrupt_size);

    memcpy(self->data, data, size);

    *destination = self;

    return IRE_OK;
}


IRE_API(ire_error_t)
ire_code_create_from_file(FILE *stream, ire_code_t **destination) {
    ire_code_t *self;
    ire_code_t tmp;
    size_t size;

    if (stream == NULL || destination == NULL) {
        return IRE_ERROR_NULL_POINTER;
    }

    tmp = (ire_code_t){0, 0, 0, 0, {0}, 0};<commit_msg>added size check for interrupt table in ire_code_t<commit_after>#include "ire.h"


IRE_API(ire_error_t)
ire_code_create(uint16_t base, uint16_t entry, uint16_t stack_base,
                uint16_t interrupt_base, uint16_t interrupt_size,
                uint16_t *interrupt_table, uint16_t size, uint8_t *data,
                ire_code_t **destination) {
    ire_code_t *self;

    if ((interrupt_size > 0 && interrupt_table == NULL) || (size > 0 && data == NULL) || destination == NULL) {
        return IRE_ERROR_NULL_POINTER;
    }

    self = malloc(sizeof(*self) + size);

    if (self == NULL) {
        return IRE_ERROR_OUT_OF_MEMORY;
    }

    self->base = base;
    self->entry = entry;
    self->stack_base = stack_base;
    self->interrupt_base = interrupt_base;
    self->size = size;

    memset(self->interrupt_table, 0, sizeof(self->interrupt_table));

    if (interrupt_size > 0) {
        memcpy(self->interrupt_table, interrupt_table, interrupt_size);
    }

    memcpy(self->data, data, size);

    *destination = self;

    return IRE_OK;
}


IRE_API(ire_error_t)
ire_code_create_from_file(FILE *stream, ire_code_t **destination) {
    ire_code_t *self;
    ire_code_t tmp;
    size_t size;

    if (stream == NULL || destination == NULL) {
        return IRE_ERROR_NULL_POINTER;
    }

    tmp = (ire_code_t){0, 0, 0, 0, {0}, 0};
{'fraction_non_alphanumeric': 0.11852134146341463, 'fraction_numerical': 0.018673780487804877, 'mean_word_length': 3.107981220657277, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 26, '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': '6454053', 'n_tokens_mistral': 965, 'n_tokens_neox': 900, 'n_words': 193}