<commit_before>#include "bigWig.h"
#include "bwCommon.h"
#include <stdlib.h>
#include <string.h>
#include <zlib.h>
#include <errno.h>

static uint32_t roundup(uint32_t v) {
    v--;
    v |= v >> 1;
    v |= v >> 2;
    v |= v >> 4;
    v |= v >> 8;
    v |= v >> 16;
    v++;
    return v;
}

//Returns the root node on success and NULL on error
static bwRTree_t *readRTreeIdx(bigWigFile_t *fp, uint64_t offset) {
    uint32_t magic;
    bwRTree_t *node;

    if(!offset) {
        if(bwSetPos(fp, fp->hdr->indexOffset)) return NULL;
    } else {
        if(bwSetPos(fp, offset)) return NULL;
    }

    if(bwRead(&magic, sizeof(uint32_t), 1, fp) != 1) return NULL;
    if(magic != IDX_MAGIC) {
        fprintf(stderr, "[readRTreeIdx] Mismatch in the magic number!\n");
        return NULL;
    }

    node = malloc(sizeof(bwRTree_t));
    if(!node) return NULL;

    if(bwRead(&(node->blockSize), sizeof(uint32_t), 1, fp) != 1) goto error;
    if(bwRead(&(node->nItems), sizeof(uint64_t), 1, fp) != 1) goto error;
    if(bwRead(&(node->chrIdxStart), sizeof(uint32_t), 1, fp) != 1) goto error;
    if(bwRead(&(node->baseStart), sizeof(uint32_t), 1, fp) != 1) goto error;<commit_msg>Initialize with 0<commit_after>#include "bigWig.h"
#include "bwCommon.h"
#include <stdlib.h>
#include <string.h>
#include <zlib.h>
#include <errno.h>

static uint32_t roundup(uint32_t v) {
    v--;
    v |= v >> 1;
    v |= v >> 2;
    v |= v >> 4;
    v |= v >> 8;
    v |= v >> 16;
    v++;
    return v;
}

//Returns the root node on success and NULL on error
static bwRTree_t *readRTreeIdx(bigWigFile_t *fp, uint64_t offset) {
    uint32_t magic;
    bwRTree_t *node;

    if(!offset) {
        if(bwSetPos(fp, fp->hdr->indexOffset)) return NULL;
    } else {
        if(bwSetPos(fp, offset)) return NULL;
    }

    if(bwRead(&magic, sizeof(uint32_t), 1, fp) != 1) return NULL;
    if(magic != IDX_MAGIC) {
        fprintf(stderr, "[readRTreeIdx] Mismatch in the magic number!\n");
        return NULL;
    }

    node = calloc(1, sizeof(bwRTree_t));
    if(!node) return NULL;

    if(bwRead(&(node->blockSize), sizeof(uint32_t), 1, fp) != 1) goto error;
    if(bwRead(&(node->nItems), sizeof(uint64_t), 1, fp) != 1) goto error;
    if(bwRead(&(node->chrIdxStart), sizeof(uint32_t), 1, fp) != 1) goto error;
    if(bwRead(&(node->baseStart), sizeof(uint32_t), 1, fp) != 1) goto error;
{'fraction_non_alphanumeric': 0.1731984829329962, 'fraction_numerical': 0.029498525073746312, 'mean_word_length': 3.1503496503496504, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 43, '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': '4372238', 'n_tokens_mistral': 984, 'n_tokens_neox': 917, 'n_words': 234}