[C++20] [Modules] Fix may-be incorrect ADL for module local entities (#123931)
[llvm-project.git] / compiler-rt / test / sanitizer_common / TestCases / Linux / malloc_usable_size.c
blob0fdec468e08aeecd48598a56d62747a87cecd2ba
1 // RUN: %clang -O2 %s -o %t && %run %t
3 // Must not be implemented, no other reason to install interceptors.
4 // XFAIL: ubsan
6 #include <assert.h>
7 #include <malloc.h>
8 #include <sanitizer/allocator_interface.h>
9 #include <stdlib.h>
11 void *p;
13 int main() {
14 assert(__sanitizer_get_allocated_size(NULL) == 0);
15 assert(malloc_usable_size(NULL) == 0);
17 int size = 1;
18 p = malloc(size);
19 assert(__sanitizer_get_allocated_size(p) == size);
20 assert(__sanitizer_get_allocated_size_fast(p) == size);
21 assert(malloc_usable_size(p) == size);
22 free(p);
24 size = 1234567;
25 p = malloc(size);
26 assert(__sanitizer_get_allocated_size(p) == size);
27 assert(__sanitizer_get_allocated_size_fast(p) == size);
28 assert(malloc_usable_size(p) == size);
29 free(p);
30 return 0;