示例#1
0
	/// Precondition: this->unique()
	/// WARNING: Use with extreme care.
	void unique_push_back(T const& v)
	{
		passert(this->unique(), "Vector is not unique");
		
		if (full())
			realloc_((size() + 1) * 3 / 2);
		*end_ = v;
		++end_;
	}
示例#2
0
	T* space1_()
	{
		if(!this->unique()
		|| end_ == limit_)
		{
			// Make unique
			realloc_((size() + 1) * 3 / 2);
		}
		
		T* ret = end_;
		++end_;
		return ret;
	}
示例#3
0
	T* space_(size_type amount)
	{
		if(!this->unique()
		|| size() + amount >= capacity())
		{
			// Make unique
			realloc_((size() + amount) * 3 / 2);
		}
		
		T* ret = end_;
		end_ += amount;
		return ret;
	}
示例#4
0
文件: memdebug.cpp 项目: Alcaro/minir
void* realloc(void* ptr, size_t size)
{
	if (!ptr) return malloc(size);
	if (!size)
	{
		free(ptr);
		return NULL;
	}
	
	void* ret=realloc_(ptr, size);
	if (!ret) abort();
	if (ignore==0)
	{
		ignore++;
		cb.realloc(ptr, ret, size);
		ignore--;
	}
	return ret;
}
示例#5
0
/*---------------------------------------------------------------------------*                                            
 * NAME: push_data(config *conf, unsigned char *ptr, unsigned int size)
 * DESC: push data to the pkt buffer using realloc
 *---------------------------------------------------------------------------*/
void push_data(config *conf, unsigned char *ptr, unsigned int size) {

  /* debug */
  debug(1, "<-----------------------[enter]\n");

  /* realloc the buffer */
  conf->buf_fuzz = (unsigned char *) realloc_(conf->buf_fuzz, conf->buf_fuzz_size + size);

  /* copy the data */
  memcpy(conf->buf_fuzz + conf->buf_fuzz_size, ptr, size);

  /* update the size */
  conf->buf_fuzz_size+=size;

  /* update the size of the blocks */
  update_block_size(conf, size);

  /* debug */
  debug(1, "<-----------------------[quit]\n");

}
示例#6
0
	/// Returned pointer is only valid until any other non-const member function
	/// is called. NOTE: Returned pointer can also be invalidated if this
	/// vector refers to some transient storage that is destroyed.
	T* mut_data()
	{
		if(!this->unique())
			realloc_(size());
		return begin_;
	}
示例#7
0
	/// NOTE: Invalidates iterators to this object
	/// Precondition: not heap allocated
	void heap_allocate()
	{
		passert(!data_, "Already heap allocated");
		realloc_(size());
	}
示例#8
0
	void reserve(size_type n)
	{
		if(capacity() < n)
			realloc_(n);
	}