示例#1
0
varstr *
varstr_cat(varstr *v, char *str)
{
	int	len = strlen(str);

	_resize(v, len);
	memcpy(v->str_pos, str, len);
	v->str_pos += len;
	return v;
}
示例#2
0
        void Node::resize(Aligner& rd)
        {
            _resize(rd);

            Node* child = _firstChild;
            while (child)
            {
                child->resize(rd);
                child = child->_nextSibling;
            }
        }
示例#3
0
	T array<T>::shift () {
		if (_size == 0)
			throw ex("pw::array::shift: no elements");

		T v = _data[0];
		T* tmp = new T[_cap];
		std::copy (_data+1, _data+_size, tmp);
		delete[] _data;
		_data = tmp;
		_resize (_size - 1);
		return v;
	}
YARPTrajectoryGen::YARPTrajectoryGen()
{
    _commands = NULL;
    _lastCommand = NULL;
    _finalCommand = NULL;
    _index = 0;

    _resize(1, 1);

    _busy = false;

    _deltaT = 0.04;
}
YARPTrajectoryGen::YARPTrajectoryGen(int size, int npnts)
{
    _commands = NULL;
    _lastCommand = NULL;
    _finalCommand = NULL;

    _index = 0;

    _resize(size, npnts);
    _busy = false;

    _deltaT = 0.04;
}
示例#6
0
	array<T>& array<T>::operator*= (size_t n) {
		size_t newsize   = n * _size;
		size_t size      = _size;
		_resize (newsize);
		T* tmp  = new T[size];
		std::copy (_data, _data+size, tmp);

		for (size_t i=1; i<n; i++)
			std::copy (tmp, tmp+size, _data+i*size);
		
		delete[] _data;
		_data = tmp;
		return *this;
	}
示例#7
0
// setNoMod
void autostring::setNoMod( const char *in ) {
    int b;

    b = len( in );

    // resize and set chunksize if needed
    if ( b * 2 + 2 > __chunksize ) {
        __chunksize = _resize( pow2above( b * 2 + 2 ) );
    }

    __strlength = b;

    _as_wstrncpyUP( __str, in, __chunksize );
}
示例#8
0
//-------------------------------------------------------------------------------------
bool Packet::build(size_t head_size, uint16_t packet_id, uint16_t packet_size, const char* packet_content)
{
	clean();

	//prepare memory
	_resize(head_size, packet_size);

	*m_packet_size = socket_api::ntoh_16(packet_size);
	*m_packet_id = socket_api::ntoh_16(packet_id);

	if (packet_content)
		memcpy(m_content, packet_content, packet_size);
	return true;
}
示例#9
0
PixelViewports ROIFinder::findRegions( const uint32_t         buffers,
                                       const PixelViewport&   pvp,
                                       const Zoom&            zoom,
                                       const uint32_t         stage,
                                       const uint128_t&       frameID,
                                       util::ObjectManager&   glObjects )
{
    PixelViewports result;
    result.push_back( pvp );

    LBLOG( LOG_ASSEMBLY ) << "ROIFinder::getObjects " << pvp << ", buffers "
                          << buffers << std::endl;

    if( zoom != Zoom::NONE )
    {
        LBWARN << "R-B optimization impossible when zoom is used"
               << std::endl;
        return result;
    }

#ifdef EQ_ROI_USE_TRACKER
    uint8_t* ticket;
    if( !_roiTracker.useROIFinder( pvp, stage, frameID, ticket ))
        return result;
#endif

    _pvpOriginal = pvp;
    _resize( _getBoundingPVP( pvp ));

    // go through depth buffer and check min/max/BG values
    // render to and read-back usefull info from FBO
    _readbackInfo( glObjects );
    glObjects.clear();

    // Analyze readed back data and find regions of interest
    _init( );

    _emptyFinder.update( &_mask[0], _wb, _hb );
    _emptyFinder.setLimits( 200, 0.002f );

    result.clear();
    _findAreas( result );

#ifdef EQ_ROI_USE_TRACKER
    _roiTracker.updateDelay( result, ticket );
#endif

    return result;
}
示例#10
0
char *
BaseExample::readLine (FILE * fp)
{
  long len;
  int c;
  char *tstr;

  try {
    if (! stre) {
      strl = MAXLEN;
      stre = new char[strl];
    }

    len = 0;
    tstr = stre;

    while (1) {
      if (len >= strl) {
	tstr = _resize (tstr, strl, strl + MAXLEN, (char)0);
        strl += MAXLEN;
	stre = tstr;
      }

      c = fgetc (fp);
      if (c == '\n' || c == '\r') {
        tstr[len] = '\0';
        break;
      }

      if (c == EOF && feof (fp)) {
        tstr[len] = '\0';
        if (feof (fp) && len == 0) tstr = 0;
        break;
      }

      tstr[len++] = c;
    }

    return tstr;
  }

  catch (...) {
    fprintf (stderr, "BaseExample::readLine(): Out of memory\n");
    exit (EXIT_FAILURE);
    return 0; 
  }
}
示例#11
0
//-------------------------------------------------------------------------------------
bool Packet::build(size_t head_size, RingBuf& ring_buf)
{
	clean();

	size_t buf_len = ring_buf.size();

	uint16_t packet_size;
	if (sizeof(packet_size) != ring_buf.peek(0, &packet_size, sizeof(packet_size))) return false;
	packet_size = socket_api::ntoh_16(packet_size);

	if (buf_len < head_size + (size_t)packet_size) return false;

	_resize(head_size, packet_size);

	ring_buf.memcpy_out(m_memory_buf, m_memory_size);

	return true;
}
示例#12
0
文件: Window.cpp 项目: luk2010/aproe
    void Window::resize(size_t width, size_t height)
    {
    	if(m_status == StatusNull)
		{
			// Create the Window
			if(create()) {
				// Call this fuction again.
				return resize(width, height);
			}
		}
		else if(m_status == StatusShown)
		{
			_resize(width, height);
		}
    	else
		{
			return;
		}
    }
示例#13
0
void autostring::setNoMod( const gwchar_t *in ) {
    int n, b;
    int m;

    b = n = len( in );
    n *= 2;

    // resize and set chunksize if needed
    if ( n + 2 > __chunksize ) {
        m = pow2above ( n + 2 );
        _resize( m );
        __chunksize = m;
    }

    __strlength = b;

    // pass in chunksize, so if all else fails, there will be a null
    //  terminator at the last character of the chunk
    _as_wstrncpy( __str, in, __chunksize );
}
示例#14
0
//-------------------------------------------------------------------------------------
bool Packet::build(size_t head_size, Pipe& pipe)
{
	clean();

	//read size
	uint16_t packet_size;
	if (sizeof(packet_size) != pipe.read((char*)&packet_size, sizeof(packet_size))){
		return false;
	}

	//prepare memory
	_resize(head_size, (size_t)socket_api::ntoh_16(packet_size));
	*m_packet_size = packet_size;

	//read other
	size_t remain = head_size + get_packet_size() - sizeof(uint16_t);
	if ((ssize_t)remain != pipe.read((char*)m_packet_id, remain)){
		clean();
		return false;
	}

	return true;
}
示例#15
0
GPUCacheManager::GPUCacheManager( constGPUCacheIndexSPtr cacheIndex, RAMPoolSPtr ramPool, const byte bytesNum,
                                   Window* wnd )
    :_iteration( 1 )
    ,_cacheIndex( cacheIndex )
    ,_gpuLoader(  new GPUAsyncLoader( wnd ))
    ,_nodeIdBeingLoaded( 0 )
    ,_cachePosBeingLoaded( 0 )
{
    LBASSERT( _cacheIndex );

    _gpuLoader->start();

    const GPULoadRespond respond = _gpuLoader->readLoadRespond();
    if( respond.status.value != GPULoadStatus::INITIALIZED )
        LBERROR << "Incorrect respond from GPU Async Loader" << std::endl;

    _gpuLoader->postCommand( GPUCommand::PAUSE );
    _gpuLoader->initialize( ramPool, cacheIndex, bytesNum );
    _resize();
    LBWARN << " new GPUCacheManager, updating GPU Cache" << std::endl;
    _gpuLoader->postCommand( GPUCommand::UPDATE );
    _gpuLoader->postCommand( GPUCommand::RESUME );
}
示例#16
0
void SString::append(char* from, Length otherLen)
{

   Length i = _length;
   std::cout << "i = " << i << std::endl;

   // find the first non null terminated char
   while(i > 1 && _theString[i] != '\0') {
      --i;
   }

   // make enough room
   _resize(i + otherLen + 1);

   // Copy it over
   for (int j = 0; j < otherLen; j++) 
   {
      _theString[i + j] = from[j];
   }

   // just in case
   _theString[_length] = '\0';
}
示例#17
0
文件: polynomial.cpp 项目: enolte/fe
  static void _add_term(polynomial& p, double coefficient, T&& t)
  {
#ifdef EXDEBUG
    using multiindex = typename polynomial::multiindex;
    if(t.m.size() > 0)
    {
      const std::size_t testing__term_max_var_index = std::max_element(std::cbegin(t.m), std::cend(t.m), [](const auto& m0, const auto& m1) { return m0.first < m1.first; })->first;
      const std::size_t testing__term_max_nvars = testing__term_max_var_index + 1;
      const std::size_t testing__polynomial_max_nvars = p.ni;
      std::cout << __func__ << "   multiindex = " << multiindex(t, std::max(testing__polynomial_max_nvars, testing__term_max_nvars)) << std::endl;
    }
    else
    {
      const std::size_t testing__polynomial_max_nvars = p.ni;
      std::cout << __func__ << "   multiindex = " << multiindex(t, testing__polynomial_max_nvars) << std::endl;
    }
#endif

    if(_rank(t) == 0)
    {
      p.constant += coefficient;
      return;
    }

    // Get new number of terms to store
    const std::size_t cur_max_nterms = _max_nterms(p);
    const std::size_t cur_max_nvars  = _max_nvars(p);

    const std::size_t new_term_index = _get_term_index(p, t);

    std::size_t new_max_nterms = cur_max_nterms;
    if(new_term_index >= cur_max_nterms)
    {
      new_max_nterms = cur_max_nterms + 1;
    }
    else
    {
      new_max_nterms = cur_max_nterms;
    }

    // Get new number of variables to store.
    const std::size_t term_max_var_index = std::max_element(std::cbegin(t.m), std::cend(t.m), [](const auto& m0, const auto& m1) { return m0.first < m1.first; })->first;
    const std::size_t term_max_nvars = term_max_var_index + 1;

    std::size_t new_max_nvars = cur_max_nvars;
    if(term_max_nvars > cur_max_nvars)
    {
      new_max_nvars = term_max_nvars;
    }
    else
    {
      new_max_nvars = cur_max_nvars;
    }

    // Grow
    _resize(p, new_max_nvars, new_max_nterms);

    // Insert new term data
    if(new_max_nterms == cur_max_nterms + 1)
    {
      p.c.insert(std::cbegin(p.c) + new_term_index, coefficient);
    }
    else
    {
      p.c[new_term_index] += coefficient;
    }

    for(auto&& m : t.m)
    {
      auto term_var_index = m.first;
      auto term_var_exponent = m.second;

      _get_exponent(p, term_var_index, new_term_index) = term_var_exponent;
    }

  }
示例#18
0
文件: magick.c 项目: kulve/pwgallery
gboolean magick_make_thumbnail(struct data *data, 
                               struct image *image,
                               const gchar *uri)
{
    MagickWand *wand;
    gdouble scale;

    g_assert(data != NULL);
    g_assert(image != NULL);
    
    g_debug("in magick_make_thumbnail");

    wand = NewMagickWand();
    g_return_val_if_fail( wand, FALSE );

    /* load image from file */
    if (!_load_image(data, wand, image)) {
        DestroyMagickWand(wand);
        return FALSE;
    }

    /* apply modifications, if nomodify is not checked */
    if (!image->nomodify) {
        if (!_apply_modifications(data, wand, image)) {
            DestroyMagickWand(wand);
            return FALSE;
        }
    }
    
    /* calculate width and height for the thumbnail */
    image->thumb_w = data->gal->thumb_w;
    switch( image->rotate ) 
    {
    case 0:
    case 180:
        scale = (gdouble)image->height / (gdouble)image->width;
        break;
    case 90:
    case 270:
        scale = (gdouble)image->width / (gdouble)image->height;
        break;
        /* FIXME: just to get some values.. */
    default:
        scale = (gdouble)image->width / (gdouble)image->height;
        break;
    }
    image->thumb_h = (gint)(image->thumb_w * scale);

    /* resize the thumbnail */
    if (!_resize(data, wand, image, image->thumb_w, image->thumb_h)) {
        DestroyMagickWand(wand);
        return FALSE;
    }

    
    /* save the thumbnail to a file */
    if (!_save(data, wand, uri)) {
        DestroyMagickWand(wand);
        return FALSE;
    }
    
    DestroyMagickWand(wand);

    return TRUE;
}
示例#19
0
文件: magick.c 项目: kulve/pwgallery
/*
 * Generate a webimage for preview or saving to a file.
 */
static MagickWand *_generate_webimage(struct data *data, 
                                      struct image *image,
                                      gint image_h,
                                      struct image_size **img_size)
{

    MagickWand *wand;
    gdouble scale;

    g_assert(data != NULL);
    g_assert(image != NULL);
    
    g_debug("in _generate_webimage");

    *img_size = g_new0(struct image_size, 1);

    wand = NewMagickWand();
    g_return_val_if_fail( wand, FALSE );

    /* load image from file */
    if (!_load_image(data, wand, image)) {
        DestroyMagickWand(wand);
        return FALSE;
    }

    /* apply modifications, if nomodify is not checked */
    if (!image->nomodify) {
        if (!_apply_modifications(data, wand, image)) {
            DestroyMagickWand(wand);
            g_free(*img_size);
            return NULL;
        }
        
        /* calculate width and height for the webimage */
        (*img_size)->height = image_h;
        switch( image->rotate ) 
            {
            case 90:
            case 270:
                scale = (gdouble)image->height / (gdouble)image->width;
                break;
            case 0:
            case 180:
                scale = (gdouble)image->width / (gdouble)image->height;
                break;
                /* FIXME: just to get some values.. */
            default:
                scale = (gdouble)image->width / (gdouble)image->height;
                break;
            }
        (*img_size)->width = (gint)((*img_size)->height * scale);
        
        /* resize the webimage */
        if (!_resize(data, wand, image, 
                     (*img_size)->width, (*img_size)->height)) {
            DestroyMagickWand(wand);
            g_free((*img_size));
            return NULL;
        }
    } else {
        /* no modify, just return original size */
        (*img_size)->height = image->height;
        (*img_size)->width = image->width;
   }
    
    return wand;
}
示例#20
0
	void push(const T& item)
	{
		_data[_size++] = item;
		
		if (_size == _capacity) _resize(_size * 2);
	}
示例#21
0
	array<T>& array<T>::operator+= (const T& val) {
		_resize (_size+1);
		_data[_size-1] = val;
		return *this;
	}
示例#22
0
	array<T>& array<T>::operator>> (T& v) {
		_normalIndex((int)_size-1, __FUNCTION__);
		v = _data[_size - 1];
		_resize (_size - 1);
		return *this;
	}
示例#23
0
void MemoryDebugger::_clip(unsigned int size)
{
 if (size < _size())
  return;
 _resize(size);
}
void ContentWindowController::resizeRelative( const QPointF& delta )
{
    const QRectF& coord = _contentWindow->getCoordinates();

    QPointF fixedPoint;
    QSizeF newSize = coord.size();
    bool isCorner = false;

    switch( _contentWindow->getBorder( ))
    {
    case ContentWindow::TOP:
        fixedPoint = QPointF( coord.left() + coord.width() * 0.5,
                              coord.bottom( ));
        newSize += QSizeF( 0, -delta.y( ));
        break;
    case ContentWindow::RIGHT:
        fixedPoint = QPointF( coord.left(),
                              coord.top() + coord.height() * 0.5 );
        newSize += QSizeF( delta.x(), 0 );
        break;
    case ContentWindow::BOTTOM:
        fixedPoint = QPointF( coord.left() + coord.width() * 0.5,
                              coord.top( ));
        newSize += QSizeF( 0, delta.y( ));
        break;
    case ContentWindow::LEFT:
        fixedPoint = QPointF( coord.right(),
                              coord.top() + coord.height() * 0.5 );
        newSize += QSizeF( -delta.x(), 0 );
        break;
    case ContentWindow::TOP_LEFT:
        fixedPoint = coord.bottomRight();
        newSize += QSizeF( -delta.x(), -delta.y( ));
        isCorner = true;
        break;
    case ContentWindow::BOTTOM_LEFT:
        fixedPoint = coord.topRight();
        newSize += QSizeF( -delta.x(), delta.y( ));
        isCorner = true;
        break;
    case ContentWindow::TOP_RIGHT:
        fixedPoint = coord.bottomLeft();
        newSize += QSizeF( delta.x(), -delta.y( ));
        isCorner = true;
        break;
    case ContentWindow::BOTTOM_RIGHT:
        fixedPoint = coord.topLeft();
        newSize += QSizeF( delta.x(), delta.y( ));
        isCorner = true;
        break;
    case ContentWindow::NOBORDER:
    default:
        return;
    }

    // Resizing from one of the corners modifies the aspect ratio.
    // Resizing from one of the sides borders tend to let the window snap back
    // to its content's aspect ratio.
    if( !isCorner && _contentWindow->getContent()->hasFixedAspectRatio( ))
    {
        if( _contentWindow->getZoomRect() == UNIT_RECTF )
            _constrainAspectRatio( newSize );
        if( _isCloseToContentAspectRatio( newSize ))
            _snapToContentAspectRatio( newSize );
    }

    _resize( fixedPoint, newSize );
}
示例#25
0
void MemoryDebugger::_reserve(unsigned int new_size)
{
 if (_capacity() >= new_size)
  return;
 _resize(new_size);
}
void YARPIntegralImage::resize(int nC, int nR, int sf)
{
	_resize(nC, nR, sf);
}
示例#27
0
FullScreenActor::FullScreenActor()
{
	_locked = false;
	theSwitchboard.SubscribeTo(this, "CameraChange");
	_resize();
}