1 // RUN: %clang -O2 %s -o %t && %run %t
2 
3 // Ubsan does not provide allocator.
4 // UNSUPPORTED: ubsan
5 
6 #include <assert.h>
7 #include <malloc.h>
8 #include <sanitizer/allocator_interface.h>
9 #include <stdlib.h>
10 
main()11 int main() {
12   assert(__sanitizer_get_allocated_size(NULL) == 0);
13   assert(malloc_usable_size(NULL) == 0);
14 
15   int size = 1234567;
16   void *p = malloc(size);
17   assert(__sanitizer_get_allocated_size(p) == size);
18   assert(malloc_usable_size(p) == size);
19   free(p);
20   return 0;
21 }
22