Changeset 733b51 in git for kernel/linear_algebra/Minor.cc


Ignore:
Timestamp:
Mar 16, 2017, 4:29:28 PM (7 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'c5facdfddea2addfd91babd8b9019161dea4b695')
Children:
f1cee38cd6cac02cfd2e0311e88e6d0feaf11505
Parents:
4fbbedd2f732aad850d2db9352ecc293ba229165
git-author:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2017-03-16 16:29:28+01:00
git-committer:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2017-03-16 16:48:34+01:00
Message:
Minor*: allocation -> omalloc, removed unueed routines, code cleanup

also fixes memory leak for minor(poly-matrix,int,SB)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/linear_algebra/Minor.cc

    r4fbbed r733b51  
    1515  _numberOfRowBlocks = 0;
    1616  _numberOfColumnBlocks = 0;
    17   delete [] _rowKey;
    18   delete [] _columnKey;
    19   _rowKey = 0;
    20   _columnKey = 0;
     17  omFree(_rowKey);
     18  _rowKey = NULL;
     19  omFree(_columnKey);
     20  _columnKey = NULL;
    2121}
    2222
     
    2727
    2828  /* allocate memory for new entries in _rowKey and _columnKey */
    29   _rowKey = new unsigned int[_numberOfRowBlocks];
    30   _columnKey = new unsigned int[_numberOfColumnBlocks];
     29  _rowKey = (unsigned*)omAlloc(_numberOfRowBlocks*sizeof(unsigned));
     30  _columnKey = (unsigned*)omAlloc(_numberOfColumnBlocks*sizeof(unsigned));
    3131
    3232  /* copying values from parameter arrays to private arrays */
     
    3939MinorKey& MinorKey::operator=(const MinorKey& mk)
    4040{
    41   if (_numberOfRowBlocks != 0)    delete [] _rowKey;
    42   if (_numberOfColumnBlocks != 0) delete [] _columnKey;
     41  omfree(_rowKey); _rowKey = NULL;
     42  omfree(_columnKey); _columnKey = NULL;
    4343  _numberOfRowBlocks = 0;
    4444  _numberOfColumnBlocks = 0;
    45   _rowKey = 0;
    46   _columnKey = 0;
    4745
    4846  _numberOfRowBlocks = mk.getNumberOfRowBlocks();
     
    5048
    5149  /* allocate memory for new entries in _rowKey and _columnKey */
    52   _rowKey = new unsigned int[_numberOfRowBlocks];
    53   _columnKey = new unsigned int[_numberOfColumnBlocks];
     50  _rowKey = (unsigned*)omalloc(_numberOfRowBlocks*sizeof(unsigned));
     51  _columnKey = (unsigned*)omalloc(_numberOfColumnBlocks*sizeof(unsigned));
    5452
    5553  /* copying values from parameter arrays to private arrays */
     
    6765{
    6866  /* free memory of _rowKey and _columnKey */
    69   if (_numberOfRowBlocks > 0) { delete [] _rowKey; }
    70   if (_numberOfColumnBlocks > 0) { delete [] _columnKey; }
     67  if (_numberOfRowBlocks > 0) { omFree(_rowKey); }
     68  if (_numberOfColumnBlocks > 0) { omFree(_columnKey); }
    7169
    7270  _numberOfRowBlocks = lengthOfRowArray;
     
    7472
    7573  /* allocate memory for new entries in _rowKey and _columnKey; */
    76   _rowKey = new unsigned int[_numberOfRowBlocks];
    77   _columnKey = new unsigned int[_numberOfColumnBlocks];
     74  _rowKey = (unsigned*)omAlloc(_numberOfRowBlocks*sizeof(unsigned));
     75  _columnKey = (unsigned*)omAlloc(_numberOfColumnBlocks*sizeof(unsigned));
    7876
    7977  /* copying values from parameter arrays to private arrays */
     
    9391
    9492  /* allocate memory for new entries in _rowKey and _columnKey */
    95   _rowKey = new unsigned int[_numberOfRowBlocks];
    96   _columnKey = new unsigned int[_numberOfColumnBlocks];
     93  _rowKey = (unsigned*)omalloc(_numberOfRowBlocks*sizeof(unsigned));
     94  _columnKey = (unsigned*)omalloc(_numberOfColumnBlocks*sizeof(unsigned));
    9795
    9896  /* copying values from parameter arrays to private arrays */
     
    108106  _numberOfRowBlocks = 0;
    109107  _numberOfColumnBlocks = 0;
    110   delete [] _rowKey;
    111   delete [] _columnKey;
    112   _rowKey = 0;
    113   _columnKey = 0;
     108  omfree(_rowKey); _rowKey = NULL;
     109  omfree(_columnKey); _columnKey = NULL;
    114110}
    115111
     
    487483  }
    488484  /* free old memory */
    489   delete [] _rowKey; _rowKey = 0;
     485  omfree(_rowKey);
     486  _rowKey = NULL;
    490487  _numberOfRowBlocks = blockIndex + 1;
    491488  /* allocate memory for new entries in _rowKey; */
    492   _rowKey = new unsigned int[_numberOfRowBlocks];
     489  _rowKey = (unsigned*)omAlloc(_numberOfRowBlocks*sizeof(unsigned));
    493490  /* copying values from mk to this MinorKey */
    494491  for (int r = 0; r < blockIndex; r++)
     
    527524  }
    528525  /* free old memory */
    529   delete [] _columnKey; _columnKey = 0;
     526  omfree(_columnKey); _columnKey = NULL;
    530527  _numberOfColumnBlocks = blockIndex + 1;
    531528  /* allocate memory for new entries in _columnKey; */
    532   _columnKey = new unsigned int[_numberOfColumnBlocks];
     529  _columnKey = (unsigned*)omAlloc(_numberOfColumnBlocks*sizeof(unsigned));
    533530  /*  copying values from mk to this MinorKey */
    534531  for (int c = 0; c < blockIndex; c++)
     
    607604    { /* In this case, _rowKey is too small. */
    608605      /* free old memory */
    609       delete [] _rowKey; _rowKey = 0;
     606      omFree(_rowKey); _rowKey = NULL;
    610607      _numberOfRowBlocks = newBitBlockIndex + 1;
    611608      /* allocate memory for new entries in _rowKey; */
    612       _rowKey = new unsigned int[_numberOfRowBlocks];
     609      _rowKey = (unsigned*)omAlloc(_numberOfRowBlocks*sizeof(unsigned));
    613610      /* initializing entries to zero */
    614611        for (int r = 0; r < _numberOfRowBlocks; r++) _rowKey[r] = 0;
     
    739736    { /* In this case, _columnKey is too small. */
    740737        /* free old memory */
    741         delete [] _columnKey; _columnKey = 0;
     738        omFree( _columnKey); _columnKey = NULL;
    742739        _numberOfColumnBlocks = newBitBlockIndex + 1;
    743740        /* allocate memory for new entries in _columnKey; */
    744         _columnKey = new unsigned int[_numberOfColumnBlocks];
     741        _columnKey = (unsigned*)omAlloc(_numberOfColumnBlocks*sizeof(unsigned));
    745742        /* initializing entries to zero */
    746743        for (int c = 0; c < _numberOfColumnBlocks; c++) _columnKey[c] = 0;
Note: See TracChangeset for help on using the changeset viewer.