Exemplo n.º 1
0
	/** free the blob's memory */
	FORCEINLINE void Free()
	{
		if (Capacity() > 0) {
			RawFree(&Hdr());
			InitEmpty();
		}
	}
Exemplo n.º 2
0
 /** free the blob's memory */
 inline void Free()
 {
     if (Capacity() > 0) {
         RawFree(&Hdr());
         InitEmpty();
     }
 }
Exemplo n.º 3
0
	/** reallocate blob data if needed */
	void SmartAlloc(size_t new_size)
	{
		if (Capacity() >= new_size) return;
		/* calculate minimum block size we need to allocate
		 * and ask allocation policy for some reasonable block size */
		new_size = AllocPolicy(header_size + new_size + tail_reserve);

		/* allocate new block and setup header */
		BlobHeader *tmp = RawAlloc(new_size);
		tmp->items = Length();
		tmp->capacity = new_size - (header_size + tail_reserve);

		/* copy existing data */
		if (tmp->items != 0)
			memcpy(tmp + 1, data, tmp->items);

		/* replace our block with new one */
		if (Capacity() > 0)
			RawFree(&Hdr());
		Init(tmp);
	}
Exemplo n.º 4
0
	/** return the number of valid data bytes in the blob */
	FORCEINLINE size_t Length() const
	{
		return Hdr().items;
	}
Exemplo n.º 5
0
	/** return reference to the actual blob size - used when the size needs to be modified */
	FORCEINLINE size_t& LengthRef()
	{
		return Hdr().items;
	}
Exemplo n.º 6
0
	/** return number of used items */
	FORCEINLINE int Size() const { return Hdr().m_num_items; }
Exemplo n.º 7
0
	/** return reference to number of used items */
	FORCEINLINE int& SizeRef() { return Hdr().m_num_items; }
Exemplo n.º 8
0
	/** return reference to the block reference counter */
	FORCEINLINE int& RefCnt() { return Hdr().m_ref_cnt; }
Exemplo n.º 9
0
	/** return reference to number of used items */
	FORCEINLINE uint& SizeRef() { return Hdr().items; }
Exemplo n.º 10
0
 /** return the number of valid data bytes in the blob */
 inline size_t Length() const
 {
     return Hdr().items;
 }
Exemplo n.º 11
0
 /** return reference to the actual blob size - used when the size needs to be modified */
 inline size_t& LengthRef()
 {
     return Hdr().items;
 }
Exemplo n.º 12
0
	/** return number of used items */
	inline uint Length() const { return Hdr().items; }
Exemplo n.º 13
0
	/** return reference to number of used items */
	inline uint& SizeRef() { return Hdr().items; }
Exemplo n.º 14
0
	/** return reference to the block reference counter */
	inline uint& RefCnt() { return Hdr().reference_count; }
Exemplo n.º 15
0
	/** return number of used items */
	FORCEINLINE uint Length() const { return Hdr().items; }
Exemplo n.º 16
0
	/** return the current blob capacity in bytes */
	FORCEINLINE size_t Capacity() const
	{
		return Hdr().capacity;
	}
Exemplo n.º 17
0
 /** return the current blob capacity in bytes */
 inline size_t Capacity() const
 {
     return Hdr().capacity;
 }
Exemplo n.º 18
0
	/** return reference to the block reference counter */
	FORCEINLINE uint& RefCnt() { return Hdr().reference_count; }