| 120 | } |
| 121 | |
| 122 | void test_dynalloc() |
| 123 | { |
| 124 | // low level dynamic memory allocation |
| 125 | CALL_SUBTEST(check_handmade_aligned_malloc()); |
| 126 | CALL_SUBTEST(check_aligned_malloc()); |
| 127 | CALL_SUBTEST(check_aligned_new()); |
| 128 | CALL_SUBTEST(check_aligned_stack_alloc()); |
| 129 | |
| 130 | for (int i=0; i<g_repeat*100; ++i) |
| 131 | { |
| 132 | CALL_SUBTEST( check_custom_new_delete<Vector4f>() ); |
| 133 | CALL_SUBTEST( check_custom_new_delete<Vector2f>() ); |
| 134 | CALL_SUBTEST( check_custom_new_delete<Matrix4f>() ); |
| 135 | CALL_SUBTEST( check_custom_new_delete<MatrixXi>() ); |
| 136 | } |
| 137 | |
| 138 | // check static allocation, who knows ? |
| 139 | #if EIGEN_MAX_STATIC_ALIGN_BYTES |
| 140 | for (int i=0; i<g_repeat*100; ++i) |
| 141 | { |
| 142 | CALL_SUBTEST(check_dynaligned<Vector4f>() ); |
| 143 | CALL_SUBTEST(check_dynaligned<Vector2d>() ); |
| 144 | CALL_SUBTEST(check_dynaligned<Matrix4f>() ); |
| 145 | CALL_SUBTEST(check_dynaligned<Vector4d>() ); |
| 146 | CALL_SUBTEST(check_dynaligned<Vector4i>() ); |
| 147 | CALL_SUBTEST(check_dynaligned<Vector8f>() ); |
| 148 | } |
| 149 | |
| 150 | { |
| 151 | MyStruct foo0; VERIFY(internal::UIntPtr(foo0.avec.data())%ALIGNMENT==0); |
| 152 | MyClassA fooA; VERIFY(internal::UIntPtr(fooA.avec.data())%ALIGNMENT==0); |
| 153 | } |
| 154 | |
| 155 | // dynamic allocation, single object |
| 156 | for (int i=0; i<g_repeat*100; ++i) |
| 157 | { |
| 158 | MyStruct *foo0 = new MyStruct(); VERIFY(internal::UIntPtr(foo0->avec.data())%ALIGNMENT==0); |
| 159 | MyClassA *fooA = new MyClassA(); VERIFY(internal::UIntPtr(fooA->avec.data())%ALIGNMENT==0); |
| 160 | delete foo0; |
| 161 | delete fooA; |
| 162 | } |
| 163 | |
| 164 | // dynamic allocation, array |
| 165 | const int N = 10; |
| 166 | for (int i=0; i<g_repeat*100; ++i) |
| 167 | { |
| 168 | MyStruct *foo0 = new MyStruct[N]; VERIFY(internal::UIntPtr(foo0->avec.data())%ALIGNMENT==0); |
| 169 | MyClassA *fooA = new MyClassA[N]; VERIFY(internal::UIntPtr(fooA->avec.data())%ALIGNMENT==0); |
| 170 | delete[] foo0; |
| 171 | delete[] fooA; |
| 172 | } |
| 173 | #endif |
| 174 | |
| 175 | } |
nothing calls this directly
no test coverage detected