File diff r4548:6a33e364fba5 → r4549:76b9213799ac
yapf/blob.hpp
Show inline comments
 
@@ -8,20 +8,20 @@ FORCEINLINE void MemCpyT(Titem_* d, cons
 
{
 
	memcpy(d, s, num_items * sizeof(Titem_));
 
}
 

	
 

	
 
/** Base class for simple binary blobs.
 
    Item is byte.
 
		The word 'simple' means:
 
		  - no configurable allocator type (always made from heap)
 
			- no smart deallocation - deallocation must be called from the same
 
			    module (DLL) where the blob was allocated
 
			- no configurable allocation policy (how big blocks should be allocated)
 
			- no extra ownership policy (i.e. 'copy on write') when blob is copied
 
			- no thread synchronization at all */
 
 *  Item is byte.
 
 *  The word 'simple' means:
 
 *    - no configurable allocator type (always made from heap)
 
 *    - no smart deallocation - deallocation must be called from the same
 
 *        module (DLL) where the blob was allocated
 
 *    - no configurable allocation policy (how big blocks should be allocated)
 
 *    - no extra ownership policy (i.e. 'copy on write') when blob is copied
 
 *    - no thread synchronization at all */
 
class CBlobBaseSimple {
 
protected:
 
	struct CHdr {
 
		int    m_size;      // actual blob size in bytes
 
		int    m_max_size;  // maximum (allocated) size in bytes
 
	};
 
@@ -75,24 +75,24 @@ public:
 
	{
 
		if (!src.IsEmpty())
 
			memcpy(GrowRawSize(src.RawSize()), src.RawData(), src.RawSize());
 
	}
 

	
 
	/** Reallocate if there is no free space for num_bytes bytes.
 
	    @return pointer to the new data to be added */
 
	 *  @return pointer to the new data to be added */
 
	FORCEINLINE int8* MakeRawFreeSpace(int num_bytes)
 
	{
 
		assert(num_bytes >= 0);
 
		int new_size = RawSize() + num_bytes;
 
		if (new_size > MaxRawSize()) SmartAlloc(new_size);
 
		FixTail();
 
		return ptr_u.m_pData + RawSize();
 
	}
 

	
 
	/** Increase RawSize() by num_bytes.
 
	@return pointer to the new data added */
 
	 *  @return pointer to the new data added */
 
	FORCEINLINE int8* GrowRawSize(int num_bytes)
 
	{
 
		int8* pNewData = MakeRawFreeSpace(num_bytes);
 
		RawSizeRef() += num_bytes;
 
		return pNewData;
 
	}