Lines Matching refs:ptr

62   void *ptr = malloc(100);  in TEST()  local
63 ASSERT_TRUE(ptr != nullptr); in TEST()
64 ASSERT_LE(100U, malloc_usable_size(ptr)); in TEST()
65 free(ptr); in TEST()
78 char *ptr = (char *)calloc(1, alloc_len); in TEST() local
79 ASSERT_TRUE(ptr != nullptr); in TEST()
80 ASSERT_LE(alloc_len, malloc_usable_size(ptr)); in TEST()
82 ASSERT_EQ(0, ptr[i]); in TEST()
84 free(ptr); in TEST()
115 char *ptr = reinterpret_cast<char*>(memalign(alignment, 100)); in TEST() local
116 ASSERT_TRUE(ptr != nullptr) << "Failed at alignment " << alignment; in TEST()
117 ASSERT_LE(100U, malloc_usable_size(ptr)) << "Failed at alignment " << alignment; in TEST()
118 ASSERT_EQ(0U, reinterpret_cast<uintptr_t>(ptr) % ((1U << i))) in TEST()
120 free(ptr); in TEST()
132 void* ptr; in TEST() local
134 ptr = memalign(align, 1024); in TEST()
135 ASSERT_TRUE(ptr != nullptr) << "Failed at align " << align; in TEST()
136 free(ptr); in TEST()
143 char *ptr = (char*)memalign(alignment, 100); in TEST() local
144 ASSERT_TRUE(ptr != nullptr); in TEST()
145 ASSERT_LE(100U, malloc_usable_size(ptr)); in TEST()
146 ASSERT_EQ(0U, (intptr_t)ptr % alignment); in TEST()
147 memset(ptr, 0x23, 100); in TEST()
149 ptr = (char*)realloc(ptr, 200); in TEST()
150 ASSERT_TRUE(ptr != nullptr); in TEST()
151 ASSERT_LE(200U, malloc_usable_size(ptr)); in TEST()
152 ASSERT_TRUE(ptr != nullptr); in TEST()
154 ASSERT_EQ(0x23, ptr[i]); in TEST()
156 memset(ptr, 0x45, 200); in TEST()
158 ptr = (char*)realloc(ptr, 300); in TEST()
159 ASSERT_TRUE(ptr != nullptr); in TEST()
160 ASSERT_LE(300U, malloc_usable_size(ptr)); in TEST()
162 ASSERT_EQ(0x45, ptr[i]); in TEST()
164 memset(ptr, 0x67, 300); in TEST()
166 ptr = (char*)realloc(ptr, 250); in TEST()
167 ASSERT_TRUE(ptr != nullptr); in TEST()
168 ASSERT_LE(250U, malloc_usable_size(ptr)); in TEST()
170 ASSERT_EQ(0x67, ptr[i]); in TEST()
172 free(ptr); in TEST()
178 char *ptr = (char *)malloc(100); in TEST() local
179 ASSERT_TRUE(ptr != nullptr); in TEST()
180 ASSERT_LE(100U, malloc_usable_size(ptr)); in TEST()
181 memset(ptr, 67, 100); in TEST()
183 ptr = (char *)realloc(ptr, 200); in TEST()
184 ASSERT_TRUE(ptr != nullptr); in TEST()
185 ASSERT_LE(200U, malloc_usable_size(ptr)); in TEST()
187 ASSERT_EQ(67, ptr[i]); in TEST()
189 free(ptr); in TEST()
194 char *ptr = (char *)malloc(200); in TEST() local
195 ASSERT_TRUE(ptr != nullptr); in TEST()
196 ASSERT_LE(200U, malloc_usable_size(ptr)); in TEST()
197 memset(ptr, 67, 200); in TEST()
199 ptr = (char *)realloc(ptr, 100); in TEST()
200 ASSERT_TRUE(ptr != nullptr); in TEST()
201 ASSERT_LE(100U, malloc_usable_size(ptr)); in TEST()
203 ASSERT_EQ(67, ptr[i]); in TEST()
205 free(ptr); in TEST()
210 char *ptr = (char *)malloc(200); in TEST() local
211 ASSERT_TRUE(ptr != nullptr); in TEST()
212 ASSERT_LE(200U, malloc_usable_size(ptr)); in TEST()
213 memset(ptr, 0x23, 200); in TEST()
215 ptr = (char *)realloc(ptr, 100); in TEST()
216 ASSERT_TRUE(ptr != nullptr); in TEST()
217 ASSERT_LE(100U, malloc_usable_size(ptr)); in TEST()
219 ASSERT_EQ(0x23, ptr[i]); in TEST()
222 ptr = (char*)realloc(ptr, 50); in TEST()
223 ASSERT_TRUE(ptr != nullptr); in TEST()
224 ASSERT_LE(50U, malloc_usable_size(ptr)); in TEST()
226 ASSERT_EQ(0x23, ptr[i]); in TEST()
229 ptr = (char*)realloc(ptr, 150); in TEST()
230 ASSERT_TRUE(ptr != nullptr); in TEST()
231 ASSERT_LE(150U, malloc_usable_size(ptr)); in TEST()
233 ASSERT_EQ(0x23, ptr[i]); in TEST()
235 memset(ptr, 0x23, 150); in TEST()
237 ptr = (char*)realloc(ptr, 425); in TEST()
238 ASSERT_TRUE(ptr != nullptr); in TEST()
239 ASSERT_LE(425U, malloc_usable_size(ptr)); in TEST()
241 ASSERT_EQ(0x23, ptr[i]); in TEST()
243 free(ptr); in TEST()
248 char *ptr = (char *)calloc(1, 100); in TEST() local
249 ASSERT_TRUE(ptr != nullptr); in TEST()
250 ASSERT_LE(100U, malloc_usable_size(ptr)); in TEST()
252 ptr = (char *)realloc(ptr, 200); in TEST()
253 ASSERT_TRUE(ptr != nullptr); in TEST()
254 ASSERT_LE(200U, malloc_usable_size(ptr)); in TEST()
256 ASSERT_EQ(0, ptr[i]); in TEST()
258 free(ptr); in TEST()
263 char *ptr = (char *)calloc(1, 200); in TEST() local
264 ASSERT_TRUE(ptr != nullptr); in TEST()
265 ASSERT_LE(200U, malloc_usable_size(ptr)); in TEST()
267 ptr = (char *)realloc(ptr, 100); in TEST()
268 ASSERT_TRUE(ptr != nullptr); in TEST()
269 ASSERT_LE(100U, malloc_usable_size(ptr)); in TEST()
271 ASSERT_EQ(0, ptr[i]); in TEST()
273 free(ptr); in TEST()
278 char *ptr = (char *)calloc(1, 200); in TEST() local
279 ASSERT_TRUE(ptr != nullptr); in TEST()
280 ASSERT_LE(200U, malloc_usable_size(ptr)); in TEST()
282 ptr = (char *)realloc(ptr, 100); in TEST()
283 ASSERT_TRUE(ptr != nullptr); in TEST()
284 ASSERT_LE(100U, malloc_usable_size(ptr)); in TEST()
286 ASSERT_EQ(0, ptr[i]); in TEST()
289 ptr = (char*)realloc(ptr, 50); in TEST()
290 ASSERT_TRUE(ptr != nullptr); in TEST()
291 ASSERT_LE(50U, malloc_usable_size(ptr)); in TEST()
293 ASSERT_EQ(0, ptr[i]); in TEST()
296 ptr = (char*)realloc(ptr, 150); in TEST()
297 ASSERT_TRUE(ptr != nullptr); in TEST()
298 ASSERT_LE(150U, malloc_usable_size(ptr)); in TEST()
300 ASSERT_EQ(0, ptr[i]); in TEST()
302 memset(ptr, 0, 150); in TEST()
304 ptr = (char*)realloc(ptr, 425); in TEST()
305 ASSERT_TRUE(ptr != nullptr); in TEST()
306 ASSERT_LE(425U, malloc_usable_size(ptr)); in TEST()
308 ASSERT_EQ(0, ptr[i]); in TEST()
310 free(ptr); in TEST()
318 void* ptr = malloc(100); in TEST() local
319 ASSERT_TRUE(ptr != nullptr); in TEST()
321 ASSERT_EQ(nullptr, realloc(ptr, SIZE_MAX)); in TEST()
323 free(ptr); in TEST()
334 void* ptr = pvalloc(100); in TEST() local
335 ASSERT_TRUE(ptr != nullptr); in TEST()
336 ASSERT_TRUE((reinterpret_cast<uintptr_t>(ptr) & (pagesize-1)) == 0); in TEST()
337 ASSERT_LE(pagesize, malloc_usable_size(ptr)); in TEST()
338 free(ptr); in TEST()
355 void* ptr = valloc(100); in TEST() local
356 ASSERT_TRUE(ptr != nullptr); in TEST()
357 ASSERT_TRUE((reinterpret_cast<uintptr_t>(ptr) & (pagesize-1)) == 0); in TEST()
358 free(ptr); in TEST()
766 for (void* ptr : ptrs) { in TEST() local
767 free(ptr); in TEST()
908 void* ptr = malloc(size); in TEST() local
909 if (ptr == nullptr) { in TEST()
913 asm volatile("" : : "r,m"(ptr) : "memory"); in TEST()
914 free(ptr); in TEST()
926 void* ptr = malloc(size); in TEST() local
927 ASSERT_TRUE(ptr != nullptr); in TEST()
929 asm volatile("" : : "r,m"(ptr) : "memory"); in TEST()
931 memset(ptr, 0x1, size); in TEST()
932 ASSERT_LE(size, malloc_usable_size(ptr)); in TEST()
933 free(ptr); in TEST()
1031 void* ptr; in TEST() local
1032 return posix_memalign(&ptr, sizeof(void *), bytes) == 0; in TEST()