src/core/alloc_func.hpp
changeset 9294 5cd9e0da420f
parent 9033 7153b87990f8
child 10164 3ff9e65f3d49
--- a/src/core/alloc_func.hpp	Tue Apr 01 17:21:24 2008 +0000
+++ b/src/core/alloc_func.hpp	Tue Apr 01 21:12:51 2008 +0000
@@ -107,9 +107,11 @@
 #else
 	/** Storing it on the heap */
 	T *data;
+	/** The length (in elements) of data in this allocator. */
+	size_t len;
 
 	/** Allocating the memory */
-	SmallStackSafeStackAlloc() : data(MallocT<T>(length)) {}
+	SmallStackSafeStackAlloc() : data(MallocT<T>(length)), len(length) {}
 	/** And freeing when it goes out of scope */
 	~SmallStackSafeStackAlloc() { free(data); }
 #endif
@@ -118,7 +120,26 @@
 	 * Gets a pointer to the data stored in this wrapper.
 	 * @return the pointer.
 	 */
-	operator T* () { return data; }
+	inline operator T* () { return data; }
+
+	/**
+	 * Gets a pointer to the data stored in this wrapper.
+	 * @return the pointer.
+	 */
+	inline T* operator -> () { return data; }
+
+	/**
+	 * Gets a pointer to the last data element stored in this wrapper.
+	 * @note needed because endof does not work properly for pointers.
+	 * @return the 'endof' pointer.
+	 */
+	inline T* EndOf() {
+#if !defined(__NDS__)
+		return endof(data);
+#else
+		return &data[len];
+#endif
+	}
 };
 
 #endif /* ALLOC_FUNC_HPP */