<commit_before>// @(#)root/io:$Id$
// Author: <NAME>   19/05/2011

/*************************************************************************
 * Copyright (C) 1995-2011, <NAME> and <NAME>.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TFPBlock                                                             //
//                                                                      //
// This class represents the encapsulation of a block request.          //
// It contains the chunks to be prefetched and also serves as a         //
// container for the information read.                                  //
// These blocks are prefetch in a special reader thread by the          //
// TFilePrefetch class.                                                 //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#include "TFPBlock.h"
#include "TStorage.h"
#include <cstdlib>


ClassImp(TFPBlock)

//__________________________________________________________________
TFPBlock::TFPBlock(Long64_t* offset, Int_t* length, Int_t nb)
{
   // Constructor.

   Long64_t aux = 0;

   fNblock = nb;
   fPos = new Long64_t[nb];
   fRelOffset = new Long64_t[nb];
   fLen = new Int_t[nb];

   for (Int_t i=0; i < nb; i++){
      fPos[i] = offset[i];
      fLen[i] = length[i];
      fRelOffset[i] = aux;
      aux += length[i];
   }
   fFullSize = aux;
   fBuffer = (char*) calloc(fFullSize, sizeof(char));
}

//__________________________________________________________________
TFPBlock::~TFPBlock()
{
   // Destructor.

   delete[] fPos;
   delete[] fLen;
   delete[] fRelOffset;
   free(fBuffer);
}


//__________________________________________________________________
void TFPBlock::SetPos(Int_t idx, Long64_t value)
{
   // Set pos value for index idx.

   fPos[idx] = value;
}


//__________________________________________________________________
void TFPBlock::SetBuffer(char* buf)
{
   // Set block buffer.

   fBuffer = buf;
}

//__________________________________________________________________
void TFPBlock::ReallocBlock(Long64_t* offset, Int_t* length, Int_t nb)
{
   // Reallocate the block's buffer based on the length
   // of the elements it will contain.

   Long64_t newSize = 0;

   fPos = (Long64_t*) TStorage::ReAlloc(fPos, nb * sizeof(Long64_t), fNblock * sizeof(Long64_t));
   fRelOffset = (Long64_t*) TStorage::ReAlloc(fRelOffset, nb * sizeof(Long64_t), fNblock * sizeof(Long64_t));
   fLen = TStorage::ReAllocInt(fLen, nb, fNblock);
   fNblock = nb;

   for(Int_t i=0; i < nb; i++){
      fPos[i] = offset[i];
      fLen[i] = length[i];
      fRelOffset[i] = newSize;
      newSize += fLen[i];
   }

   if (newSize > fFullSize) {
     fBuffer = (char*) realloc(fBuffer, newSize);
     fFullSize = newSize;
   }   
}
<commit_msg>Fix Solaris error: cstdlib pulls things into std::, not ::.<commit_after>// @(#)root/io:$Id$
// Author: <NAME>   19/05/2011

/*************************************************************************
 * Copyright (C) 1995-2011, <NAME> and <NAME>.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TFPBlock                                                             //
//                                                                      //
// This class represents the encapsulation of a block request.          //
// It contains the chunks to be prefetched and also serves as a         //
// container for the information read.                                  //
// These blocks are prefetch in a special reader thread by the          //
// TFilePrefetch class.                                                 //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#include "TFPBlock.h"
#include "TStorage.h"
#include <cstdlib>

using std::calloc;
using std::free;
using std::realloc;

ClassImp(TFPBlock)

//__________________________________________________________________
TFPBlock::TFPBlock(Long64_t* offset, Int_t* length, Int_t nb)
{
   // Constructor.

   Long64_t aux = 0;

   fNblock = nb;
   fPos = new Long64_t[nb];
   fRelOffset = new Long64_t[nb];
   fLen = new Int_t[nb];

   for (Int_t i=0; i < nb; i++){
      fPos[i] = offset[i];
      fLen[i] = length[i];
      fRelOffset[i] = aux;
      aux += length[i];
   }
   fFullSize = aux;
   fBuffer = (char*) calloc(fFullSize, sizeof(char));
}

//__________________________________________________________________
TFPBlock::~TFPBlock()
{
   // Destructor.

   delete[] fPos;
   delete[] fLen;
   delete[] fRelOffset;
   free(fBuffer);
}


//__________________________________________________________________
void TFPBlock::SetPos(Int_t idx, Long64_t value)
{
   // Set pos value for index idx.

   fPos[idx] = value;
}


//__________________________________________________________________
void TFPBlock::SetBuffer(char* buf)
{
   // Set block buffer.

   fBuffer = buf;
}

//__________________________________________________________________
void TFPBlock::ReallocBlock(Long64_t* offset, Int_t* length, Int_t nb)
{
   // Reallocate the block's buffer based on the length
   // of the elements it will contain.

   Long64_t newSize = 0;

   fPos = (Long64_t*) TStorage::ReAlloc(fPos, nb * sizeof(Long64_t), fNblock * sizeof(Long64_t));
   fRelOffset = (Long64_t*) TStorage::ReAlloc(fRelOffset, nb * sizeof(Long64_t), fNblock * sizeof(Long64_t));
   fLen = TStorage::ReAllocInt(fLen, nb, fNblock);
   fNblock = nb;

   for(Int_t i=0; i < nb; i++){
      fPos[i] = offset[i];
      fLen[i] = length[i];
      fRelOffset[i] = newSize;
      newSize += fLen[i];
   }

   if (newSize > fFullSize) {
     fBuffer = (char*) realloc(fBuffer, newSize);
     fFullSize = newSize;
   }   
}

{'fraction_non_alphanumeric': 0.18902978472427012, 'fraction_numerical': 0.013565319964612209, 'mean_word_length': 1.6799683919399446, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 38, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3356924', 'n_tokens_mistral': 1856, 'n_tokens_neox': 1743, 'n_words': 437}