equal
deleted
inserted
replaced
22 * @note the memory contains garbage data (i.e. possibly non-zero values). |
22 * @note the memory contains garbage data (i.e. possibly non-zero values). |
23 * @param T the type of the variable(s) to allocation. |
23 * @param T the type of the variable(s) to allocation. |
24 * @param num_elements the number of elements to allocate of the given type. |
24 * @param num_elements the number of elements to allocate of the given type. |
25 * @return NULL when num_elements == 0, non-NULL otherwise. |
25 * @return NULL when num_elements == 0, non-NULL otherwise. |
26 */ |
26 */ |
27 template <typename T> FORCEINLINE T* MallocT(size_t num_elements) |
27 template <typename T> |
|
28 static FORCEINLINE T *MallocT(size_t num_elements) |
28 { |
29 { |
29 /* |
30 /* |
30 * MorphOS cannot handle 0 elements allocations, or rather that always |
31 * MorphOS cannot handle 0 elements allocations, or rather that always |
31 * returns NULL. So we do that for *all* allocations, thus causing it |
32 * returns NULL. So we do that for *all* allocations, thus causing it |
32 * to behave the same on all OSes. |
33 * to behave the same on all OSes. |
46 * @note the memory contains all zero values. |
47 * @note the memory contains all zero values. |
47 * @param T the type of the variable(s) to allocation. |
48 * @param T the type of the variable(s) to allocation. |
48 * @param num_elements the number of elements to allocate of the given type. |
49 * @param num_elements the number of elements to allocate of the given type. |
49 * @return NULL when num_elements == 0, non-NULL otherwise. |
50 * @return NULL when num_elements == 0, non-NULL otherwise. |
50 */ |
51 */ |
51 template <typename T> FORCEINLINE T* CallocT(size_t num_elements) |
52 template <typename T> |
|
53 static FORCEINLINE T *CallocT(size_t num_elements) |
52 { |
54 { |
53 /* |
55 /* |
54 * MorphOS cannot handle 0 elements allocations, or rather that always |
56 * MorphOS cannot handle 0 elements allocations, or rather that always |
55 * returns NULL. So we do that for *all* allocations, thus causing it |
57 * returns NULL. So we do that for *all* allocations, thus causing it |
56 * to behave the same on all OSes. |
58 * to behave the same on all OSes. |
71 * @param T the type of the variable(s) to allocation. |
73 * @param T the type of the variable(s) to allocation. |
72 * @param t_ptr the previous allocation to extend/shrink. |
74 * @param t_ptr the previous allocation to extend/shrink. |
73 * @param num_elements the number of elements to allocate of the given type. |
75 * @param num_elements the number of elements to allocate of the given type. |
74 * @return NULL when num_elements == 0, non-NULL otherwise. |
76 * @return NULL when num_elements == 0, non-NULL otherwise. |
75 */ |
77 */ |
76 template <typename T> FORCEINLINE T* ReallocT(T *t_ptr, size_t num_elements) |
78 template <typename T> |
|
79 FORCEINLINE T *ReallocT(T *t_ptr, size_t num_elements) |
77 { |
80 { |
78 /* |
81 /* |
79 * MorphOS cannot handle 0 elements allocations, or rather that always |
82 * MorphOS cannot handle 0 elements allocations, or rather that always |
80 * returns NULL. So we do that for *all* allocations, thus causing it |
83 * returns NULL. So we do that for *all* allocations, thus causing it |
81 * to behave the same on all OSes. |
84 * to behave the same on all OSes. |