File diff r15609:02b794721f9c → r15610:623a23fb6560
src/misc/blob.hpp
Show inline comments
 
@@ -16,7 +16,8 @@
 
#include "../core/mem_func.hpp"
 
#include <new>
 

	
 
/** Base class for simple binary blobs.
 
/**
 
 * Base class for simple binary blobs.
 
 *  Item is byte.
 
 *  The word 'simple' means:
 
 *    - no configurable allocator type (always made from heap)
 
@@ -102,7 +103,8 @@ protected:
 
		return (BlobHeader*)MallocT<byte>(num_bytes);
 
	}
 

	
 
	/** Return header pointer to the static BlobHeader with
 
	/**
 
	 * Return header pointer to the static BlobHeader with
 
	 * both items and capacity containing zero */
 
	static FORCEINLINE BlobHeader *Zero()
 
	{
 
@@ -231,7 +233,8 @@ public:
 
		}
 
	}
 

	
 
	/** Reallocate if there is no free space for num_bytes bytes.
 
	/**
 
	 * Reallocate if there is no free space for num_bytes bytes.
 
	 *  @return pointer to the new data to be added */
 
	FORCEINLINE byte *Prepare(size_t num_bytes)
 
	{
 
@@ -240,7 +243,8 @@ public:
 
		return data + Length();
 
	}
 

	
 
	/** Increase Length() by num_bytes.
 
	/**
 
	 * Increase Length() by num_bytes.
 
	 *  @return pointer to the new data added */
 
	FORCEINLINE byte *Append(size_t num_bytes)
 
	{
 
@@ -286,7 +290,8 @@ public:
 
	}
 
};
 

	
 
/** Blob - simple dynamic T array. T (template argument) is a placeholder for any type.
 
/**
 
 * Blob - simple dynamic T array. T (template argument) is a placeholder for any type.
 
 *  T can be any integral type, pointer, or structure. Using Blob instead of just plain C array
 
 *  simplifies the resource management in several ways:
 
 *  1. When adding new item(s) it automatically grows capacity if needed.
 
@@ -380,7 +385,8 @@ public:
 
		return (T*)base::Append(num_items * type_size);
 
	}
 

	
 
	/** Ensures that given number of items can be added to the end of Blob. Returns pointer to the
 
	/**
 
	 * Ensures that given number of items can be added to the end of Blob. Returns pointer to the
 
	 *  first free (unused) item */
 
	FORCEINLINE T *MakeFreeSpace(size_t num_items)
 
	{