Commits

jsagevid committed 008bdde

Fixed a bug where the temp allocator would not align correctly.

Comments (0)

Files changed (2)

 		/// to service the allocations.
 		///
 		/// If there is not enough memory in the buffer to match requests for scratch
-		/// memory, memory from the default_allocator will be returned instaed.
+		/// memory, memory from the default_allocator will be returned instead.
 		Allocator &default_scratch_allocator();
 
 		/// Shuts down the global memory allocators created by init().
 
 	// Aligns p to the specified alignment by moving it forward if necessary
 	// and returns the result.
-	inline void *memory::align_forward(void *p, uint32_t align) {
+	inline void *memory::align_forward(void *p, uint32_t align)
+	{
 		uintptr_t pi = uintptr_t(p);
 		const uint32_t mod = pi % align;
 		if (mod)
 	}
 
 	/// Returns the result of advancing p by the specified number of bytes
-	inline void *memory::pointer_add(void *p, uint32_t bytes)	{
+	inline void *memory::pointer_add(void *p, uint32_t bytes)
+	{
 		return (void*)((char *)p + bytes);
 	}
 
-	inline const void *memory::pointer_add(const void *p, uint32_t bytes)	{
+	inline const void *memory::pointer_add(const void *p, uint32_t bytes)
+	{
 		return (const void*)((const char *)p + bytes);
 	}
 
+	inline template<class T> T *memory::pointer_add(T *p, uint32_t bytes)
+	{
+		return (T*)((char *)p + bytes);
+	}
+
+	inline template<class T> const T *memory::pointer_add(const T *p, uint32_t bytes)
+	{
+		return (const T*)((char *)p + bytes);
+	}
+
 	/// Returns the result of moving p back by the specified number of bytes
-	inline void *memory::pointer_sub(void *p, uint32_t bytes)	{
+	inline void *memory::pointer_sub(void *p, uint32_t bytes)
+	{
 		return (void*)((char *)p - bytes);
 	}
 
-	inline const void *memory::pointer_sub(const void *p, uint32_t bytes)	{
+	inline const void *memory::pointer_sub(const void *p, uint32_t bytes)
+	{
 		return (const void*)((const char *)p - bytes);
 	}
 }
 			_end = _start + to_allocate;
 			*(void **)_start = 0;
 			_p += sizeof(void *);
-			memory::align_forward(p, align);
+			_p = (char *)memory::align_forward(_p, align);
 		}
 		void *result = _p;
 		_p += size;