Ver Fonte

Fix allocators docs

Daniele Bartolini há 12 anos atrás
pai
commit
f20bbc0935
3 ficheiros alterados com 16 adições e 2 exclusões
  1. 7 0
      src/core/mem/Allocator.h
  2. 8 1
      src/core/mem/MallocAllocator.h
  3. 1 1
      src/core/mem/Memory.h

+ 7 - 0
src/core/mem/Allocator.h

@@ -31,6 +31,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 {
 
+/// Base class for memory allocators.
 class Allocator
 {
 public:
@@ -38,8 +39,14 @@ public:
 						Allocator() {}
 	virtual				~Allocator() {}
 
+	/// Allocates @size bytes of memory aligned to the specified
+	/// @align byte and returns a pointer to the first allocated byte.
 	virtual void*		allocate(size_t size, size_t align = memory::DEFAULT_ALIGN) = 0;
+
+	/// Deallocates a previously allocated block of memory pointed by @data.
 	virtual void		deallocate(void* data) = 0;
+
+	/// Returns the total number of bytes allocated.
 	virtual size_t		allocated_size() = 0;
 
 private:

+ 8 - 1
src/core/mem/MallocAllocator.h

@@ -30,6 +30,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 {
 
+/// Allocator based on C malloc().
 class MallocAllocator : public Allocator
 {
 public:
@@ -37,15 +38,21 @@ public:
 				MallocAllocator();
 				~MallocAllocator();
 
+	/// @copydoc Allocator::allocate()
 	void*		allocate(size_t size, size_t align = memory::DEFAULT_ALIGN);
+
+	/// @copydoc Allocator::deallocate()
 	void		deallocate(void* data);
 
+	/// @copydoc Allocator::allocated_size()
 	size_t		allocated_size();
+
+	/// Returns the size in bytes of the block of memory pointed by @data
 	size_t		get_size(void* data);
 
 private:
 
-	//! Holds the number of bytes of an allocation
+	// Holds the number of bytes of an allocation
 	struct Header
 	{
 		uint32_t	size;

+ 1 - 1
src/core/mem/Memory.h

@@ -38,7 +38,7 @@ namespace memory
 const uint32_t	PADDING_VALUE	= 0xFFFFFFFFu;	//!< Value used to fill unused memory
 const size_t	DEFAULT_ALIGN	= 4;			//!< Default memory alignment in bytes
 
-//! Returns the point32_ter p aligned to the desired align
+/// Returns the pointer @p aligned to the desired @align byte
 inline void* align(void* p, size_t align)
 {
 	uintptr_t ptr = (uintptr_t)p;