Changeset 592 for trunk/src2/core


Ignore:
Timestamp:
Feb 25, 2007 8:53:05 PM (17 years ago)
Author:
dkearney
Message:

changed ints to unsigned ints inside of the rappture buffer object and fixed some corner cases.
adjusted the Ptr.h and Outcome.[h,cpp] files to get rid of warnings from not returning the correct data type.

Location:
trunk/src2/core
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src2/core/Outcome.cpp

    r441 r592  
    44 *
    55 *  AUTHOR:  Michael McLennan, Purdue University
    6  *  Copyright (c) 2004-2006  Purdue Research Foundation
     6 *  Copyright (c) 2004-2007  Purdue Research Foundation
    77 * ----------------------------------------------------------------------
    88 *  See the file "license.terms" for information on usage and
     
    1010 * ======================================================================
    1111 */
    12 #include "RpOutcome.h"
     12#include "Outcome.h"
    1313
    1414using namespace Rappture;
     
    4545}
    4646
     47/// Destructor
     48Outcome::~Outcome()
     49{}
     50
    4751/**
    4852 *  Assign an error condition to the outcome.
     
    5458    _remarkPtr = Ptr<std::string>(new std::string(errmsg));
    5559    _contextPtr.clear();
     60    return *this;
    5661}
    5762
     
    6570    _remarkPtr.clear();
    6671    _contextPtr.clear();
     72    return *this;
    6773}
    6874
     
    96102        _contextPtr = oc._contextPtr;
    97103    }
     104    return *this;
    98105}
    99106
  • trunk/src2/core/Outcome.h

    r576 r592  
    44 *
    55 *  AUTHOR:  Michael McLennan, Purdue University
    6  *  Copyright (c) 2004-2006  Purdue Research Foundation
     6 *  Copyright (c) 2004-2007  Purdue Research Foundation
    77 * ----------------------------------------------------------------------
    88 *  See the file "license.terms" for information on usage and
     
    2828    Outcome(const Outcome& status);
    2929    Outcome& operator=(const Outcome& status);
     30    virtual ~Outcome();
    3031
    3132    virtual Outcome& error(const char* errmsg, int status=1);
  • trunk/src2/core/Ptr.h

    r576 r592  
    9797    clear();
    9898    _pc = new PtrCore(ptr);
     99    return *this;
    99100}
    100101
     
    108109    clear();
    109110    _pc = ptr._pc;
     111    return *this;
    110112}
    111113
  • trunk/src2/core/RpBuffer.cc

    r583 r592  
    165165 * @return Number of the bytes used in the buffer.
    166166 */
    167 int
     167unsigned int
    168168SimpleBuffer::size() const
    169169{
     
    194194SimpleBuffer::append(const char* bytes, int nbytes)
    195195{
    196     int newSize = 0;
     196    unsigned int newSize = 0;
    197197    char *newBuffer = NULL;
    198198
     
    217217    }
    218218
    219     newSize = _size + nbytes;
     219    newSize = (unsigned int)(_size + nbytes);
    220220
    221221    // ensure that our smallest buffer is 200 bytes
     
    247247    memcpy((void*) (_buf + _size), (void*) bytes, (size_t) nbytes);
    248248
    249     _size = _size + nbytes;
     249    _size = _size + (unsigned int) nbytes;
    250250
    251251    return nbytes;
     
    262262SimpleBuffer::read(const char* bytes, int nbytes)
    263263{
    264     int bytesRead = 0;
     264    unsigned int bytesRead = 0;
    265265
    266266    // SimpleBuffer is empty.
     
    274274    }
    275275
     276    // User specified negative buffer size
     277    if (nbytes <= 0) {
     278        return 0;
     279    }
     280
    276281    // make sure we don't read off the end of our buffer
    277     if ( (_pos + nbytes) >= _size) {
     282    if ( (_pos + nbytes) >= _size ) {
    278283        bytesRead = (_size - _pos);
    279284    }
    280285    else {
    281         bytesRead = nbytes;
    282     }
    283 
    284     if (bytesRead < 0) {
     286        bytesRead = (unsigned int) nbytes;
     287    }
     288
     289    if (bytesRead <= 0) {
    285290        return 0;
    286291    }
     
    290295    }
    291296
    292     _pos = _pos + bytesRead;
    293 
    294     return bytesRead;
     297    _pos = (_pos + bytesRead);
     298
     299    return (int)bytesRead;
    295300}
    296301
     
    316321            _pos = 0;
    317322        }
    318         else if (offset >= _size) {
     323        else if (offset >= (int)_size) {
    319324            /* dont go off the end of data */
    320325            _pos = _size - 1;
    321326        }
    322327        else {
    323             _pos = _pos + offset;
     328            _pos = (unsigned int)(_pos + offset);
    324329        }
    325330    }
     
    334339        }
    335340        else {
    336             _pos = _pos + offset;
     341            _pos = (unsigned int)(_pos + offset);
    337342        }
    338343    }
    339344    else if (whence == SEEK_END) {
    340         if (offset <= (-1*_size)) {
     345        if (offset <= (-1*((int)_size))) {
    341346            /* dont go off the beginning of data */
    342347            _pos = 0;
     
    347352        }
    348353        else {
    349             _pos = (_size - 1) + offset;
     354            _pos = (unsigned int)((_size - 1) + offset);
    350355        }
    351356    }
     
    365370SimpleBuffer::tell()
    366371{
    367    return _pos;
     372   return (int)_pos;
    368373}
    369374
     
    832837{
    833838    int tBufSize = 0;
    834     int tBufAvl = 2*bin.size();
     839    unsigned int tBufAvl = 2*bin.size();
    835840    char* tBuf = new char[tBufAvl];
    836841
     
    853858{
    854859    int tBufSize = 0;
    855     int tBufAvl = bin.size();
     860    unsigned int tBufAvl = bin.size();
    856861    char* tBuf = new char[tBufAvl];
    857862
  • trunk/src2/core/RpBuffer.h

    r583 r592  
    9191
    9292    const char* bytes() const;
    93     int size() const;
     93    unsigned int size() const;
    9494
    9595    SimpleBuffer& clear();
     
    117117
    118118    /// Position offset within the buffer's memory
    119     int _pos;
     119    unsigned int _pos;
    120120
    121121    /// Size of the used memory in the buffer
    122     int _size;
     122    unsigned int _size;
    123123
    124124    /// Total space available in the buffer
    125     int _spaceAvl;
     125    unsigned int _spaceAvl;
    126126
    127127    /// State of the last file like operation.
Note: See TracChangeset for help on using the changeset viewer.