Changeset 2ffb6ae in tol


Ignore:
Timestamp:
Feb 9, 2011, 9:34:10 AM (16 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
8f99127
Parents:
db1c18b
Message:

Fixes #1085

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@3140 be4846ae-f051-483a-831f-b64e7d08527f

Location:
tol
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • tol/OIS/ois.cpp

    rdb1c18b r2ffb6ae  
    6363BArray<BSystemDat*> BOis::loadModeOptions_;
    6464
    65 size_t BOis::_MaxBlockLength_ = 1024*1024;
     65size_t BOis::_MaxBlockLength_    = 1024*1024;
     66int    BOis::_NumAuxiliarBuffer_ = 9;
    6667
    6768#ifdef TRACE_OIS_FILE
    … …  
    9596  source_        (),
    9697  packages_      (),
    97   auxilarBuffer(),
    98   auxilarBufferSize_(0)
    99 {
    100   AllocAuxilarBuffer(_MaxBlockLength_);
     98  auxilarBuffer  (NULL),
     99  auxilarBufferSize_(NULL)
     100{
     101  auxilarBuffer = new char*[_NumAuxiliarBuffer_];
     102  auxilarBufferSize_ = new int[_NumAuxiliarBuffer_];
     103  for(int i=0; i<_NumAuxiliarBuffer_; i++)
     104  {
     105    auxilarBufferSize_[i] = 0;
     106    auxilarBuffer[i] = NULL;
     107    AllocAuxilarBuffer(i,_MaxBlockLength_);
     108  }
    101109  InitBuild();
    102110}
    … …  
    108116{
    109117  Close();
    110   if(auxilarBuffer)
    111   {
     118  if(auxilarBuffer)
     119  {
     120    for(int i=0; i<_NumAuxiliarBuffer_; i++)
     121    {
     122      if(auxilarBuffer[i])
     123      {
     124        delete [] auxilarBuffer[i];
     125      }
     126    }
    112127    delete [] auxilarBuffer;
    113   }
    114 }
    115 
    116 
    117 //--------------------------------------------------------------------
    118  char* BOis::AllocAuxilarBuffer(int size)
    119 //--------------------------------------------------------------------
    120 {
    121   if(size>auxilarBufferSize_)
    122   {
    123     if(auxilarBuffer)
     128    auxilarBuffer = NULL;
     129  }
     130  if(auxilarBufferSize_)
     131  {
     132    delete [] auxilarBufferSize_;
     133    auxilarBufferSize_ = NULL;
     134  }
     135}
     136
     137
     138//--------------------------------------------------------------------
     139 char* BOis::AllocAuxilarBuffer(int id, int size)
     140//--------------------------------------------------------------------
     141{
     142  if((id<0) || (id>=_NumAuxiliarBuffer_))
     143  {
     144    Error(BText("[OIS] FATAL ERROR IN BOis::AllocAuxilarBuffer id=")+id+
     145    " out of range [0,BOis::_NumAuxiliarBuffer_="+BOis::_NumAuxiliarBuffer_+"] ");
     146    exit(-1);   
     147  }
     148  if(size>auxilarBufferSize_[id])
     149  {
     150    if(auxilarBuffer[id])
    124151    {
    125       delete [] auxilarBuffer;
    126       auxilarBuffer = NULL;
     152      delete [] auxilarBuffer[id];
     153      auxilarBuffer[id] = NULL;
    127154    } 
    128     auxilarBufferSize_ = int(double(size)*1.2);
    129     auxilarBuffer = new char[auxilarBufferSize_];
    130   }
    131   return(auxilarBuffer);
     155    auxilarBufferSize_[id] = int(double(size)*1.2);
     156    auxilarBuffer[id] = new char[auxilarBufferSize_[id] ];
     157  }
     158  return(auxilarBuffer[id]);
    132159}
    133160
    … …  
    168195//--------------------------------------------------------------------
    169196{ 
    170   BText dirOriPath = GetFilePath(tolFile);
     197  BText absTolPath = GetStandardAbsolutePath(tolFile);
     198  BText absDirPath = GetFilePath(absTolPath);
    171199  BText filPrf = GetFilePrefix(tolFile);
    172   BText dirAbsPath = Replace(RemoveLastSlash(
    173     GetStandardAbsolutePath(dirOriPath)),"\\","/");
    174   BText oisSubPath = PlainPath(dirAbsPath+ArchiveExtension());
     200  BText oisSubPath = PlainPath(absDirPath+filPrf+ArchiveExtension());
    175201  connection_ = Replace(oisDefRoot_,"\\","/")+"module/"+oisSubPath;
    176202  address_.concept_  = "";
    177203  address_.version_  = "";
    178   address_.node_     = dirOriPath+filPrf;
     204  address_.node_     = "";
    179205  options_.tolSourceSearchPaths_.AllocBuffer(1);
    180   options_.tolSourceSearchPaths_[0].alias_ = ToName(GetFilePrefix(dirAbsPath));
    181   options_.tolSourceSearchPaths_[0].value_ = dirAbsPath;
    182 /*
     206  options_.tolSourceSearchPaths_[0].alias_ = ToName(absDirPath);
     207  options_.tolSourceSearchPaths_[0].value_ = absDirPath;
     208
    183209//Std(BText("\nTRACE BOis::SetModulePath('")+tolFile+"'");
    184210//Std(BText("\nTRACE   connection_='")+connection_+"'");
    … …  
    186212//Std(BText("\nTRACE   alias_='")+options_.tolSourceSearchPaths_[0].alias_+"'");
    187213//Std(BText("\nTRACE   value_='")+options_.tolSourceSearchPaths_[0].value_+"'");
    188 */
     214/* */
    189215}
    190216
  • tol/OIS/oiscompress.cpp

    rdb1c18b r2ffb6ae  
    4949  else //BZip2 Compress method
    5050  {
    51     char* dest = AllocAuxilarBuffer(destLen);
     51    char* dest = AllocAuxilarBuffer(5,destLen);
    5252    int cmprs = BZ2_bzBuffToBuffCompress
    5353    (
    … …  
    289289    else
    290290    {
    291       char* source = AllocAuxilarBuffer(sourceLen);
     291      char* source = AllocAuxilarBuffer(6,sourceLen);
    292292      if(!source)
    293293      {
  • tol/OIS/oiscreator.cpp

    rdb1c18b r2ffb6ae  
    309309  FILE* file=fopen(path.String(),"rb");
    310310  if(!file) { return(false); }
    311   char* contens = AllocAuxilarBuffer(size+1);
     311  char* contens = AllocAuxilarBuffer(2,size+1);
    312312  int r = fread(contens,1,size,file); 
    313313  contens[r]='\0';
    … …  
    413413  int s = x.Size();
    414414  EWrite(s, stream);
    415   BCoefDeg* buf = (BCoefDeg*)AllocAuxilarBuffer(sizeof(BCoefDeg)*x.Size());
     415  BCoefDeg* buf = (BCoefDeg*)AllocAuxilarBuffer(3,sizeof(BCoefDeg)*x.Size());
    416416  for(int i=0; i<x.Size(); i++)
    417417  {
    … …  
    10701070  else
    10711071  {
    1072     BDat* buf = (BDat*)AllocAuxilarBuffer(sizeof(BDat)*r*c);
     1072    BDat* buf = (BDat*)AllocAuxilarBuffer(4,sizeof(BDat)*r*c);
    10731073    int i, j, k;
    10741074    for(i=k=0; i<r; i++) { for(j=0; j<c; j++) { buf[k++] = x(i,j); } }
  • tol/OIS/oisloader.cpp

    rdb1c18b r2ffb6ae  
    397397  if(control_.typeSizes_.sizeof_BCoefDeg_==sizeof(BCoefDegOld))
    398398  {
    399     BCoefDegOld* buf = (BCoefDegOld*)AllocAuxilarBuffer(sizeof(BCoefDegOld)*s);
     399    BCoefDegOld* buf = (BCoefDegOld*)AllocAuxilarBuffer(0,sizeof(BCoefDegOld)*s);
    400400    Ensure(Read(buf,sizeof(BCoefDegOld),s,stream));
    401401    for(i=0; i<x.Size(); i++)
    … …  
    407407  else if(control_.typeSizes_.sizeof_BCoefDeg_==sizeof(BCoefDeg))
    408408  {
    409     BCoefDeg* buf = (BCoefDeg*)AllocAuxilarBuffer(sizeof(BCoefDeg)*s);
     409    BCoefDeg* buf = (BCoefDeg*)AllocAuxilarBuffer(1,sizeof(BCoefDeg)*s);
    410410    Ensure(Read(buf,sizeof(BCoefDeg),s,stream));
    411411    for(i=0; i<x.Size(); i++)
    … …  
    15131513{
    15141514  bool isOza = (options_.compressor_.fileManager_.engine_==BAE_ZIPARC_);
     1515  if(!isOza) { return(false); }
    15151516  BDir dir(path);
    15161517  lostSource_=!dir.Exist();
    1517   bool updated;
    1518   if(lostSource_)
    1519   {
    1520     updated = true;
    1521   }
    1522   else
    1523   {
    1524     BText name = BText("._tol_source_/")+PlainPath(path);
    1525     BStream* fn = isOza?streamHandler_->Open(name,name):NULL;
    1526     source_.Add(fn); 
    1527     if(isOza && !fn)
     1518  if(lostSource_) { return(false); }
     1519  bool updated = false;
     1520  BText name = BText("._tol_source_/")+PlainPath(path);
     1521  BStream* fn = streamHandler_->Open(name,name);
     1522  source_.Add(fn); 
     1523  if(fn)
     1524  {
     1525    int size    = dir.Bytes();
     1526    int oldSize = (int)tolSources_[n].bytes_;
     1527    if(oldSize==size)
    15281528    {
    1529       updated = true;
    1530     }
    1531     else
    1532     {
    1533       int size    = dir.Bytes();
    1534       int oldSize = (int)tolSources_[n].bytes_;
    1535       if(oldSize!=size)
     1529      time_t time      = dir.Time();
     1530      BDate  date      = BTimer::TimeToDate(time);
     1531      BDate  oldDate   = tolSources_[n].release_;
     1532      double diff      = DifInSeconds(oldDate,date);
     1533      if(fabs(diff)<1.0)
    15361534      {
    1537         updated = false;
     1535        updated = true;
    15381536      }
    1539       else
     1537      else 
    15401538      {
    1541         time_t time      = dir.Time();
    1542         BDate  date      = BTimer::TimeToDate(time);
    1543         BDate  oldDate   = tolSources_[n].release_;
    1544         double diff      = DifInSeconds(oldDate,date);
    1545         if(fabs(diff)<1.0)
     1539        FILE* file=fopen(path.String(),"rb");
     1540        if(!file)
    15461541        {
    1547           updated = true;
     1542          Warning(I2("Cannot check if source file ",
     1543                     "No se pudo comprobar si el fichero fuente ")+path+
     1544                  I2(" is synchronized with this module.",
     1545                     " está sincronizado con este módulo."));
    15481546        }
    1549         else if(!isOza)
    1550         {
    1551           updated = false;
    1552         }
    1553         else if(fn && fn->Bytes()!=size)
    1554         {
    1555           updated = false;
    1556         }
    1557         else
     1547        else
    15581548        {
    1559           FILE* file=fopen(path.String(),"rb");
    1560           if(!file)
    1561           {
    1562             Warning(I2("Cannot check if source file ",
    1563                        "No se pudo comprobar si el fichero fuente ")+path+
    1564                     I2(" is synchronized with this module.",
    1565                        " está sincronizado con este módulo."));
    1566             updated = true;
    1567           }
    1568           else
    1569           {
    1570             char* contens = AllocAuxilarBuffer(2*size+2);
    1571             char* oldCont = contens+(size+1);
    1572             int r = fread(contens,1,size,file); 
    1573             contens[r]='\0';
    1574             fclose(file);
     1549          char* contens = AllocAuxilarBuffer(7,size+1);
     1550          char* oldCont = AllocAuxilarBuffer(8,size+1);
     1551          int r = fread(contens,1,size,file); 
     1552          fclose(file);
     1553          if(r==size)
     1554          {
     1555            contens[size]='\0';
    15751556            assert(r==size);
    15761557            Read(oldCont,1,size,fn);
    15771558            oldCont[size]='\0';
    1578             int cmp = memcmp(oldCont,contens,r);
     1559            int cmp = memcmp(oldCont,contens,size);
    15791560            updated = (cmp==0);
    1580             if(updated)
     1561            if(!updated)
    15811562            {
    15821563            //tolSources_[n].release_ = date;
     1564              Std(BText("[OIS] File ")+path+" has changed and module should be rebuilt.\n");
    15831565              SetFileTime(path, BTimer::DateToTime(tolSources_[n].release_));
    15841566            }
  • tol/OIS/oisxml.cpp

    rdb1c18b r2ffb6ae  
    535535        }
    536536      }
    537       if(!obsoleteSource_) { obsoleteSource_ = !CheckUpdatedSource(n, path); }
     537      if(!obsoleteSource_) {
     538       obsoleteSource_ = !CheckUpdatedSource(n, path); }
    538539    }
    539540  }
  • tol/OIS/tol_ois.h

    rdb1c18b r2ffb6ae  
    604604//auxiliar buffer 
    605605  static size_t _MaxBlockLength_;
    606   char* auxilarBuffer;
    607   int auxilarBufferSize_;
     606  static int _NumAuxiliarBuffer_;
     607
     608  char** auxilarBuffer;
     609  int* auxilarBufferSize_;
    608610 
    609611//Functions
    … …  
    615617  bool  Warning(const BText& msg) const;
    616618  BSyntaxObject* NullError(const BText& msg) const;
    617   char* AllocAuxilarBuffer(int size);
     619  char* AllocAuxilarBuffer(int id, int size);
    618620
    619621public:
  • tol/tol_version_def.h

    rdb1c18b r2ffb6ae  
    2525#define VERSION_MINOR   0
    2626#define VERSION_RELEASE 1
    27 #define VERSION_BUILD   "0.53.alpha"
     27#define VERSION_BUILD   "0.54.alpha"
    2828
    2929#if defined(_MSC_VER)
Note: See TracChangeset for help on using the changeset viewer.