[AA] Rename CaptureInfo -> CaptureAnalysis (NFC) (#116842)
[llvm-project.git] / compiler-rt / test / msan / tsearch.cpp
blob1a2c466caccdc98bc708c37918406ab6e13c54e7
1 // RUN: %clangxx_msan -O0 -g %s -o %t && %run %t
3 // tdestroy is a GNU extension
4 // UNSUPPORTED: target={{.*(netbsd|freebsd).*}}
6 #include <assert.h>
7 #include <search.h>
8 #include <stdlib.h>
10 int compare(const void *pa, const void *pb) {
11 int a = *(const int *)pa;
12 int b = *(const int *)pb;
13 if (a < b)
14 return -1;
15 else if (a > b)
16 return 1;
17 else
18 return 0;
21 void myfreenode(void *p) {
22 delete (int *)p;
25 int main(void) {
26 void *root = NULL;
27 for (int i = 0; i < 5; ++i) {
28 int *p = new int(i);
29 void *q = tsearch(p, &root, compare);
30 if (q == NULL)
31 exit(1);
32 if (*(int **)q != p)
33 delete p;
36 tdestroy(root, myfreenode);
38 return 0;