src/core/alloc_type.hpp
changeset 11049 f8bbc9635251
parent 10429 1b99254f9607
child 11050 091271fcfbb9
equal deleted inserted replaced
11047:f4e7290c23b9 11049:f8bbc9635251
    35 
    35 
    36 	/**
    36 	/**
    37 	 * Gets a pointer to the data stored in this wrapper.
    37 	 * Gets a pointer to the data stored in this wrapper.
    38 	 * @return the pointer.
    38 	 * @return the pointer.
    39 	 */
    39 	 */
    40 	inline operator T* () { return data; }
    40 	FORCEINLINE operator T* () { return data; }
    41 
    41 
    42 	/**
    42 	/**
    43 	 * Gets a pointer to the data stored in this wrapper.
    43 	 * Gets a pointer to the data stored in this wrapper.
    44 	 * @return the pointer.
    44 	 * @return the pointer.
    45 	 */
    45 	 */
    46 	inline T* operator -> () { return data; }
    46 	FORCEINLINE T* operator -> () { return data; }
    47 
    47 
    48 	/**
    48 	/**
    49 	 * Gets a pointer to the last data element stored in this wrapper.
    49 	 * Gets a pointer to the last data element stored in this wrapper.
    50 	 * @note needed because endof does not work properly for pointers.
    50 	 * @note needed because endof does not work properly for pointers.
    51 	 * @return the 'endof' pointer.
    51 	 * @return the 'endof' pointer.
    52 	 */
    52 	 */
    53 	inline T* EndOf() {
    53 	FORCEINLINE T* EndOf() {
    54 #if !defined(__NDS__)
    54 #if !defined(__NDS__)
    55 		return endof(data);
    55 		return endof(data);
    56 #else
    56 #else
    57 		return &data[len];
    57 		return &data[len];
    58 #endif
    58 #endif
    72 	/**
    72 	/**
    73 	 * Memory allocator for a single class instance.
    73 	 * Memory allocator for a single class instance.
    74 	 * @param size the amount of bytes to allocate.
    74 	 * @param size the amount of bytes to allocate.
    75 	 * @return the given amounts of bytes zeroed.
    75 	 * @return the given amounts of bytes zeroed.
    76 	 */
    76 	 */
    77 	void *operator new(size_t size) { return CallocT<byte>(size); }
    77 	FORCEINLINE void *operator new(size_t size) { return CallocT<byte>(size); }
    78 
    78 
    79 	/**
    79 	/**
    80 	 * Memory allocator for an array of class instances.
    80 	 * Memory allocator for an array of class instances.
    81 	 * @param size the amount of bytes to allocate.
    81 	 * @param size the amount of bytes to allocate.
    82 	 * @return the given amounts of bytes zeroed.
    82 	 * @return the given amounts of bytes zeroed.
    83 	 */
    83 	 */
    84 	void *operator new[](size_t size) { return CallocT<byte>(size); }
    84 	FORCEINLINE void *operator new[](size_t size) { return CallocT<byte>(size); }
    85 
    85 
    86 	/**
    86 	/**
    87 	 * Memory release for a single class instance.
    87 	 * Memory release for a single class instance.
    88 	 * @param ptr  the memory to free.
    88 	 * @param ptr  the memory to free.
    89 	 * @param size the amount of allocated memory (unused).
    89 	 * @param size the amount of allocated memory (unused).
    90 	 *
    90 	 *
    91 	 * @warning The value of the \a size parameter can only be trusted for
    91 	 * @warning The value of the \a size parameter can only be trusted for
    92 	 *          classes that have their own (virtual) destructor method.
    92 	 *          classes that have their own (virtual) destructor method.
    93 	 */
    93 	 */
    94 	void operator delete(void *ptr, size_t size) { free(ptr); }
    94 	FORCEINLINE void operator delete(void *ptr, size_t size) { free(ptr); }
    95 
    95 
    96 	/**
    96 	/**
    97 	 * Memory release for an array of class instances.
    97 	 * Memory release for an array of class instances.
    98 	 * @param ptr  the memory to free.
    98 	 * @param ptr  the memory to free.
    99 	 * @param size the amount of allocated memory (unused).
    99 	 * @param size the amount of allocated memory (unused).
   100 	 *
   100 	 *
   101 	 * @warning The value of the \a size parameter can only be trusted for
   101 	 * @warning The value of the \a size parameter can only be trusted for
   102 	 *          classes that have their own (virtual) destructor method.
   102 	 *          classes that have their own (virtual) destructor method.
   103 	 */
   103 	 */
   104 	void operator delete[](void *ptr, size_t size) { free(ptr); }
   104 	FORCEINLINE void operator delete[](void *ptr, size_t size) { free(ptr); }
   105 };
   105 };
   106 
   106 
   107 #endif /* ALLOC_TYPE_HPP */
   107 #endif /* ALLOC_TYPE_HPP */