<commit_before>/*
 * Copyright (c) 2014 <NAME>
 * See LICENSE
*/
#include <stdio.h>
#include <stdlib.h>
#include "libmidi.h"

//convert big-endian data to little endian in-place, does nothing on BE host
void be_to_le(void* vdata, int bytes)
{
//NOTE: these preprocessor variables are gcc-specific!
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
    char tmp;
    unsigned char* data = (unsigned char*)vdata;

    for (int i = 0; i < bytes / 2; i++){
        tmp = *(data + i);
        *(data + i) = *(data + bytes - 1 - i);
        *(data + bytes - 1 - i) = tmp;
    }
#endif
}

int VLV_read(FILE * buf, uint32_t * val, int * bytes_read)
{
  uint8_t byte;
  uint8_t a;
  int i;

  *val = 0x00;

  for (i = 0; i < 4; i++){
    if (fread(&byte, 1, 1, buf) != 1)
      return FILE_IO_ERROR;

    *val = ((*val << 7) | (byte % 128));

    // if ((byte & 0x80) == 0x00){
      if (bytes_read != NULL)
        *bytes_read = i + 1;
      return SUCCESS;
    }
  }
  //VLVs smaller than 4 bytes, should never reach here
  return VLV_ERROR;
}


int MIDIFile_load(MIDIFile * midi, const char * filename)
{
  int r;

  midi->file = fopen(filename, "rb");
  if (!midi->file)
    return FILE_IO_ERROR;

  r = MIDIHeader_load(&midi->header, midi->file);
  if (r != SUCCESS)
    fclose(midi->file);

  return r;
}

void MIDIFile_delete(MIDIFile * midi)
{
    fclose(midi->file);
}<commit_msg>accidentally commented out a line, oops<commit_after>/*
 * Copyright (c) 2014 <NAME>
 * See LICENSE
*/
#include <stdio.h>
#include <stdlib.h>
#include "libmidi.h"

//convert big-endian data to little endian in-place, does nothing on BE host
void be_to_le(void* vdata, int bytes)
{
//NOTE: these preprocessor variables are gcc-specific!
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
    char tmp;
    unsigned char* data = (unsigned char*)vdata;

    for (int i = 0; i < bytes / 2; i++){
        tmp = *(data + i);
        *(data + i) = *(data + bytes - 1 - i);
        *(data + bytes - 1 - i) = tmp;
    }
#endif
}

int VLV_read(FILE * buf, uint32_t * val, int * bytes_read)
{
  uint8_t byte;
  uint8_t a;
  int i;

  *val = 0x00;

  for (i = 0; i < 4; i++){
    if (fread(&byte, 1, 1, buf) != 1)
      return FILE_IO_ERROR;

    *val = ((*val << 7) | (byte % 128));

    if ((byte & 0x80) == 0x00){
      if (bytes_read != NULL)
        *bytes_read = i + 1;
      return SUCCESS;
    }
  }
  //VLVs smaller than 4 bytes, should never reach here
  return VLV_ERROR;
}


int MIDIFile_load(MIDIFile * midi, const char * filename)
{
  int r;

  midi->file = fopen(filename, "rb");
  if (!midi->file)
    return FILE_IO_ERROR;

  r = MIDIHeader_load(&midi->header, midi->file);
  if (r != SUCCESS)
    fclose(midi->file);

  return r;
}

void MIDIFile_delete(MIDIFile * midi)
{
    fclose(midi->file);
}
{'fraction_non_alphanumeric': 0.1553153153153153, 'fraction_numerical': 0.023063063063063063, 'mean_word_length': 2.7362045760430687, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 21, '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': '3450860', 'n_tokens_mistral': 1171, 'n_tokens_neox': 1076, 'n_words': 313}