예제 #1
0
	/** free the blob's memory */
	FORCEINLINE void Free()
	{
		if (Capacity() > 0) {
			RawFree(&Hdr());
			InitEmpty();
		}
	}
예제 #2
0
 /** free the blob's memory */
 inline void Free()
 {
     if (Capacity() > 0) {
         RawFree(&Hdr());
         InitEmpty();
     }
 }
예제 #3
0
파일: blob.hpp 프로젝트: jemmyw/openttd
	/** 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);
	}
예제 #4
0
	/** return the number of valid data bytes in the blob */
	FORCEINLINE size_t Length() const
	{
		return Hdr().items;
	}
예제 #5
0
	/** return reference to the actual blob size - used when the size needs to be modified */
	FORCEINLINE size_t& LengthRef()
	{
		return Hdr().items;
	}
예제 #6
0
	/** return number of used items */
	FORCEINLINE int Size() const { return Hdr().m_num_items; }
예제 #7
0
	/** return reference to number of used items */
	FORCEINLINE int& SizeRef() { return Hdr().m_num_items; }
예제 #8
0
	/** return reference to the block reference counter */
	FORCEINLINE int& RefCnt() { return Hdr().m_ref_cnt; }
예제 #9
0
	/** return reference to number of used items */
	FORCEINLINE uint& SizeRef() { return Hdr().items; }
예제 #10
0
 /** return the number of valid data bytes in the blob */
 inline size_t Length() const
 {
     return Hdr().items;
 }
예제 #11
0
 /** return reference to the actual blob size - used when the size needs to be modified */
 inline size_t& LengthRef()
 {
     return Hdr().items;
 }
예제 #12
0
	/** return number of used items */
	inline uint Length() const { return Hdr().items; }
예제 #13
0
	/** return reference to number of used items */
	inline uint& SizeRef() { return Hdr().items; }
예제 #14
0
	/** return reference to the block reference counter */
	inline uint& RefCnt() { return Hdr().reference_count; }
예제 #15
0
	/** return number of used items */
	FORCEINLINE uint Length() const { return Hdr().items; }
예제 #16
0
	/** return the current blob capacity in bytes */
	FORCEINLINE size_t Capacity() const
	{
		return Hdr().capacity;
	}
예제 #17
0
 /** return the current blob capacity in bytes */
 inline size_t Capacity() const
 {
     return Hdr().capacity;
 }
예제 #18
0
	/** return reference to the block reference counter */
	FORCEINLINE uint& RefCnt() { return Hdr().reference_count; }