Beispiel #1
0
static void *coalesce(void *bp)
{
#ifdef __DEBUG__
	fprintf(stderr, "Coalescing...\n");
#endif
	size_t p = isAllocated(getBlockHeader(getPrevBlock(bp))); //allocated "physically" previous block?
	size_t n = isAllocated(getBlockHeader(getNextBlock(bp))); //allocated "physicall" next block?
	size_t size = getSize(getBlockHeader(bp)); //get block size
	if(p && n) { //no coalescing
		return bp;
	}
	else if(!p && n) //previous block is empty!
	{
#ifdef __DEBUG__
		fprintf(stderr, "Merging %u(size : %u) and %u(size : %u)...\n", getPrevBlock(bp), getSize(getBlockHeader(getPrevBlock(bp))), bp, getSize(getBlockHeader(bp)));
#endif
		erase(size, bp); //delete current block
		erase(getSize(getBlockHeader(getPrevBlock(bp))), getPrevBlock(bp)); //delete previous block
		size += getSize(getBlockHeader(getPrevBlock(bp)));
		set(getBlockFooter(bp), setMask(size, 0));
		set(getBlockHeader(getPrevBlock(bp)), setMask(size, 0));
		push_back(size, getPrevBlock(bp)); //add summed block
		return getPrevBlock(bp);
	}
	else if(p && !n) //next block is empty!
	{
#ifdef __DEBUG__
		fprintf(stderr, "Merging %u(size : %u) and %u(size : %u)...\n", bp, getSize(getBlockHeader(bp)), getNextBlock(bp), getSize(getBlockHeader(getNextBlock(bp))));
#endif
		erase(size, bp); //delete current
		erase(getSize(getBlockHeader(getNextBlock(bp))), getNextBlock(bp)); //delete next
		size += getSize(getBlockHeader(getNextBlock(bp)));
		set(getBlockHeader(bp), setMask(size, 0));
		set(getBlockFooter(bp), setMask(size, 0));
		push_back(size, bp); //add summed block
		return bp;
	}
	else //both block are empty!
	{
#ifdef __DEBUG__
		fprintf(stderr, "Merging %u(size : %u), %u(size : %u) and %u(size : %u)...\n", getPrevBlock(bp), getSize(getBlockHeader(getPrevBlock(bp))), bp, getSize(getBlockHeader(bp)), getNextBlock(bp), getSize(getBlockHeader(getNextBlock(bp))));
#endif
		erase(size, bp); //delete every adjacent block
		erase(getSize(getBlockHeader(getPrevBlock(bp))), getPrevBlock(bp));
		erase(getSize(getBlockHeader(getNextBlock(bp))), getNextBlock(bp));
		size += getSize(getBlockHeader(getNextBlock(bp))) + getSize(getBlockHeader(getPrevBlock(bp)));
		set(getBlockHeader(getPrevBlock(bp)), setMask(size, 0));
		set(getBlockFooter(getNextBlock(bp)), setMask(size, 0));
		push_back(size, getPrevBlock(bp)); //sum up
		return getPrevBlock(bp);
	}
}
 /*
 * Return cursor to beginning.
 */
 void MemoryOArchive::clear()
 {
    if (!isAllocated()) {
       UTIL_THROW("Archive is not allocated");
    }  
    cursor_ = begin(); 
 }
Beispiel #3
0
void
evgSeqRam::enable() {
    if(isAllocated()) {
        BITSET32(m_pReg, SeqControl(m_id), EVG_SEQ_RAM_ARM);
    } else 
        throw std::runtime_error("Trying to enable Unallocated seqRam");
}
Beispiel #4
0
//----------------------------------------------------------
void ofTexture::loadData(const ofFloatPixels & pix, int glFormat){
	if(!isAllocated()){
		allocate(pix.getWidth(), pix.getHeight(), ofGetGlInternalFormat(pix), ofGetUsingArbTex(), glFormat, ofGetGlType(pix));
	}
	ofSetPixelStoreiAlignment(GL_UNPACK_ALIGNMENT,pix.getWidth(),pix.getBytesPerChannel(),ofGetNumChannelsFromGLFormat(glFormat));
	loadData(pix.getData(), pix.getWidth(), pix.getHeight(), glFormat, ofGetGlType(pix));
}
Beispiel #5
0
/* tries to allocate new page with input pid. if pid is available, bitmask flag
 * is made. otherwise returns failure. The page is not only allocated in memory
 * and not written until later call
 */
RC_t BitmapPagedFile::allocatePageWithPID(PID_t pid) {
    if(pid >= NUM_BITS_HEADER) { // pid outside valid range
        return RC_OutOfRange;
    }

    // if pid is within range of current allocated pages
    if(pid < numContentPages) {
        if(isAllocated(pid)) { // pid already allocated
            return RC_AlreadyAllocated;
        }
        allocate(pid);
        return RC_OK;
    }

    // pid not in current page ranges, but within maximum page bounds
    /*int bytes = (pid - numContentPages)/8;
      for(; numContentPages < pid; numContentPages++) { // check this
      if(numContentPages%8 == 0) {
      header[numContentPages/8] = 0;
      }
      }
     */
    numContentPages = pid + 1;
    allocate(pid);
    return RC_OK;
}
void ofPixels_<PixelType>::setImageType(ofImageType imageType){
	if(!isAllocated() || imageType==getImageType()) return;
	ofPixels_<PixelType> dst;
	dst.allocate(width,height,imageType);
	PixelType * dstPtr = &dst[0];
	PixelType * srcPtr = &pixels[0];
	int diffNumChannels = 0;
	if(dst.getNumChannels()<getNumChannels()){
		diffNumChannels = getNumChannels()-dst.getNumChannels();
	}
	for(int i=0;i<width*height;i++){
		const PixelType & gray = *srcPtr;
		for(int j=0;j<dst.getNumChannels();j++){
			if(j<getNumChannels()){
				*dstPtr++ =  *srcPtr++;
			}else if(j<3){
				*dstPtr++ = gray;
			}else{
				*dstPtr++ = ofColor_<PixelType>::limit();
			}
		}
		srcPtr+=diffNumChannels;
	}
	swap(dst);
}
Beispiel #7
0
//----------------------------------------------------------
ofPoint ofTexture::getCoordFromPoint(float xPos, float yPos) const{
	
	ofPoint temp;
	
	if (!isAllocated()) return temp;
	
#ifndef TARGET_OPENGLES	
	if (texData.textureTarget == GL_TEXTURE_RECTANGLE_ARB){
		
		temp.set(xPos, yPos);
		
	} else {
#endif		
		// non arb textures are 0 to 1, so we 
		// (a) convert to a pct: 
		
		float pctx = xPos / texData.width;
		float pcty = yPos / texData.height;
		
		// (b) mult by our internal pct (since we might not be 0-1 internally)
		
		pctx *= texData.tex_t;
		pcty *= texData.tex_u;
		
		temp.set(pctx, pcty);
		
#ifndef TARGET_OPENGLES	
	}
#endif		
	
	return temp;
	
}
//==============================================================================
AztecDVBR_Matrix::~AztecDVBR_Matrix(){

   if (isAllocated()) {
      delete [] Amat_->val;
      delete [] Amat_->bindx;
      delete [] Amat_->rpntr;
      delete [] Amat_->bpntr;
      delete [] Amat_->indx;

      delete [] remoteInds_;
      delete [] remoteBlockSizes_;

      setAllocated(false);
   }

   if (isLoaded()) {
      free(Amat_->cpntr);
      free(external_);
      free(extern_index_);
      free(update_index_);
      free(data_org_);
      delete [] orderingUpdate_;

      setLoaded(false);
   }

   delete [] nnzPerRow_;
   localNNZ_ = 0;

   AZ_matrix_destroy(&Amat_);
   Amat_ = NULL;
}
Beispiel #9
0
void
AbstractAnalysisArrayData::valuesReady()
{
    GMX_RELEASE_ASSERT(isAllocated(), "There must be some data");
    if (bReady_)
    {
        return;
    }
    bReady_ = true;

    std::vector<AnalysisDataValue>::const_iterator valueIter = value_.begin();
    AnalysisDataModuleManager                     &modules   = moduleManager();
    modules.notifyDataStart(this);
    for (int i = 0; i < rowCount(); ++i, valueIter += columnCount())
    {
        AnalysisDataFrameHeader header(i, xvalue(i), 0);
        modules.notifyFrameStart(header);
        modules.notifyPointsAdd(
                AnalysisDataPointSetRef(
                        header, pointSetInfo_,
                        constArrayRefFromVector<AnalysisDataValue>(valueIter,
                                                                   valueIter + columnCount())));
        modules.notifyFrameFinish(header);
    }
    modules.notifyDataFinish();
}
Beispiel #10
0
 /*
 * Reset cursor to beginning, prepare to reread.
 */
 void MemoryIArchive::reset()
 {
    if (!isAllocated()) {
       UTIL_THROW("Archive is not allocated");
    }  
    cursor_ = begin(); 
 }
Beispiel #11
0
 // return the value for the given alarm ID
 time_t TimeAlarmsClass::read(AlarmID_t ID)
 {
   if(isAllocated(ID))
     return Alarm[ID].value ;
   else 	
     return dtINVALID_TIME;  
 }
/*
 * Display debug info (1 line)
 */
void		CChangeTrackerBase::displayTrackerInfo( const char *headerStr, const char *footerStrNotAllocd, NLMISC::CLog *log ) const
{
	if ( isAllocated() )
		log->displayNL( "%sAllocated, %d changes, smid %d mutid %d", headerStr, nbChanges(), smid(), mutid() );
	else
		log->displayNL( "%sNot allocated%s", headerStr, footerStrNotAllocd );
}
Beispiel #13
0
 // return the alarm type for the given alarm ID
 dtAlarmPeriod_t TimeAlarmsClass::readType(AlarmID_t ID)
 {
   if(isAllocated(ID))
     return (dtAlarmPeriod_t)Alarm[ID].Mode.alarmType ;
   else 	
     return dtNotAllocated;  
 }
//==============================================================================
int AztecDVBR_Matrix::getBlockRow(int blkRow,
                                  double* val,
                                  int* blkColInds,
                                  int numNzBlks) const {

   if (!isAllocated()) return(1);

   int index;

   if (!inUpdate(blkRow, index)) {
      fei::console_out() << "AztecDVBR_Matrix::getBlockRow: ERROR: blkRow "
           << blkRow << " not in local update list." << FEI_ENDL;
      return(1);
   }

   //for each block, we need to find its block column index
   //in the bindx array, then go to that same position in the indx
   //array to find out how many point-entries are in that block.
   //We can then use the indx entry to go to the val array and get
   //the data.

   int nnzBlks = 0, nnzPts = 0;
   int err = getNumBlocksPerRow(blkRow, nnzBlks);
   if (err) return(err);
   err = getNumNonzerosPerRow(blkRow, nnzPts);
   if (err) return(err);
   
   if (numNzBlks != nnzBlks) return(1);

   int offset = 0;
   int blkCounter = 0;
   const int* blkUpdate = amap_->getBlockUpdate();
   for(int indb = Amat_->bpntr[index]; indb<Amat_->bpntr[index+1]; indb++) {

      int numEntries = Amat_->indx[indb+1] - Amat_->indx[indb];
      int valOffset = Amat_->indx[indb];

      if (isLoaded()) {
         int ind = Amat_->bindx[indb];
         if (ind < N_update_) {
            blkColInds[blkCounter++] = blkUpdate[orderingUpdate_[ind]];
         }
         else {
            blkColInds[blkCounter++] = external_[ind-N_update_];
         }
      }
      else {
         blkColInds[blkCounter++] = Amat_->bindx[indb];
      }

      //ok, now we're ready to get the stuff.
      for(int i=0; i<numEntries; i++) {
         val[offset + i] = Amat_->val[valOffset + i];
      }

      offset += numEntries;
   }

   return(0);
}
Beispiel #15
0
static void* find_fit(size_t size) //find best place
{
#ifdef __DEBUG__
	fprintf(stderr, "find fitting place - size : %d\n", size);
#endif
	void* bp;
	void* s;
	size_t sizeIndex = size;
	for(s = getSegBySize(size); ; s = getSegBySize(sizeIndex))  //increase seg size
	{
		sizeIndex = getNextSize(sizeIndex);
		for(bp = s; ; bp = getNextNode(bp)) //iterate list
		{
			if(bp==NULL) break;
#ifdef __DEBUG__
			fprintf(stderr, "searching : %u / allocated? : %u / size? : %u\n", getBlockHeader(bp), isAllocated(getBlockHeader(bp)), getSize(getBlockHeader(bp)));
#endif
			if(!isAllocated(getBlockHeader(bp)) && size <= getSize(getBlockHeader(bp)))
			{
				return bp;
			}
			if(isTail(bp)) break;
		}
		if(s==seg_inf) break;
	}
	return NULL;
}
Beispiel #16
0
 void TimeAlarmsClass::enable(AlarmID_t ID)
 {
   if(isAllocated(ID)) {
     Alarm[ID].Mode.isEnabled = (Alarm[ID].value != 0) && (Alarm[ID].onTickHandler != 0) ;  // only enable if value is non zero and a tick handler has been set
     Alarm[ID].updateNextTrigger(); // trigger is updated whenever  this is called, even if already enabled	 
   }
 }
int CIppImage::Alloc(IppiSize roi, int nchannels, int precision, int align)
{
  int size;
  int du      = (((precision & 255)+7)/8);
  int newStep = roi.width * nchannels * du;

  if(align)
    newStep += BYTES_PAD(roi.width, nchannels,du);

  if( isAllocated() && Height() == roi.height && Step() == newStep )
  {
    m_roi        = roi;
    m_nchannels  = nchannels;
    m_precision  = precision;
    m_step       = newStep;
    return 0;
  }

  Free();

  m_roi        = roi;
  m_nchannels  = nchannels;
  m_precision  = precision;
  m_step       = newStep;

  size = m_step * roi.height;
  m_imageData = (Ipp8u*)ippMalloc(size);
  m_allocated = m_imageData != 0;

  return m_imageData ? 0 : -1;
} // CIppImage::Alloc()
Beispiel #18
0
 // write the given value to the given alarm
 void TimeAlarmsClass::write(AlarmID_t ID, time_t value)
 {
   if(isAllocated(ID))
   {
     Alarm[ID].value = value;
     enable(ID);  // update trigger time
   }
 }
Beispiel #19
0
//----------------------------------------------------------
void ofTexture::loadData(const ofFloatPixels & pix){
	if(!isAllocated()){
		allocate(pix);
	}else{
		ofSetPixelStoreiAlignment(GL_UNPACK_ALIGNMENT,pix.getBytesStride());
		loadData(pix.getData(), pix.getWidth(), pix.getHeight(), ofGetGlFormat(pix), ofGetGlType(pix));
	}
}
Beispiel #20
0
void
AbstractAnalysisArrayData::setColumnCount(int ncols)
{
    GMX_RELEASE_ASSERT(!isAllocated(),
                       "Cannot change column count after data has been allocated");
    AbstractAnalysisData::setColumnCount(0, ncols);
    pointSetInfo_ = AnalysisDataPointSetInfo(0, ncols, 0, 0);
}
Beispiel #21
0
Allocator::Result BitAllocator::allocate(Address addr)
{
    if (addr < m_base || isAllocated(addr))
        return InvalidAddress;

    m_array.set((addr - m_base) / m_chunkSize);
    return Success;
}
//==============================================================================
void AztecDVBR_Matrix::put(double s){

   if (!isAllocated()) return;

   for(int i=0; i<localNNZ_; i++) {
      Amat_->val[i] = s;
   }

   return;
}
Beispiel #23
0
 // returns the number of allocated timers
 uint8_t TimeAlarmsClass::count()
 {
    uint8_t c = 0; 
    for(uint8_t id = 0; id < dtNBR_ALARMS; id++)
    {
       if(isAllocated(id))
         c++;
    }
    return c;
 }
Beispiel #24
0
 void TimeAlarmsClass::free(AlarmID_t ID)
 {
   if(isAllocated(ID))
   {
     Alarm[ID].Mode.isEnabled = false;
 	Alarm[ID].Mode.alarmType = dtNotAllocated;
     Alarm[ID].onTickHandler = 0;
 	Alarm[ID].value = 0;
 	Alarm[ID].nextTrigger = 0;   	
   }
 }
 void performcopy(AbstractImage& dest, int bytewidth, int height, int xoffset, int yoffset) const {
   assert(isAllocated());
   const uint8_t *sourcedata = (uint8_t *) this->addr;
   uint8_t *destdata = (uint8_t *) dest.data();
   for (int j=0;j<height;j++) {
     for (int i=0;i<bytewidth;i++) {
       destdata[j*bytewidth + i] = sourcedata[(j + yoffset) * this->row_stride + i + xoffset];
     }
   }
   dest.setData(destdata);
 }
Beispiel #26
0
void ofxImageROI::setROI()
{
    if (isAllocated()) {
        cornerPoints[0].set(0, 0);
        cornerPoints[1].set(this->width, 0);
        cornerPoints[2].set(this->width, this->height);
        cornerPoints[3].set(0, this->height);

        bSetROI = true;
    }
}
Beispiel #27
0
//--------------------------------------------------------------
void ofVbo::VertexAttribute::setData(const float * attrib0x, int numCoords, int total, int usage, int stride, bool normalize){
	if (!isAllocated()) {
		allocate();
	}
	GLsizeiptr size = (stride == 0) ? numCoords * sizeof(float) : stride;
	this->stride = size;
	this->numCoords = numCoords;
	this->offset = 0;
	this->normalize = normalize;
	setData(total * size, attrib0x, usage);
};
Beispiel #28
0
 /*
 * Clear memory block (reset to empty state).
 */
 void MemoryIArchive::clear()
 {
    if (!isAllocated()) {
       UTIL_THROW("Archive is not allocated");
    }
    if (!ownsData_) {  
       UTIL_THROW("Archive does not own data");
    }
    cursor_ = begin(); 
    end_ = begin();
 }
Beispiel #29
0
bool
evgSeqRam::alloc(evgSoftSeq* softSeq) {
    assert(softSeq);
    interruptLock ig;
    if(!isAllocated()) {
        softSeq->setSeqRam(this);
        m_softSeq = softSeq;
        return true;
    } else {
        return false;
    }
}
Beispiel #30
0
RC_t BitmapPagedFile::disposePage(PID_t pid) {
    if(pid >= numContentPages) {
        return RC_OutOfRange; /* pid not within allocated pid range, nothing is done */
    }

    if(isAllocated(pid)) {
        deallocate(pid); /* deallocates mapped bit in header, defers actual
                            physical disposal of data until later */
        return RC_OK;
    }
    return RC_NotAllocated;
}