Add missing zstd.h to coregrind Makefile.am noinst_HEADERS
[valgrind.git] / memcheck / tests / darwin / env.c
blob9e36b1574ecd4ca02e9ceb4bbb749154744e4d63
1 #include <assert.h>
2 #include <stdlib.h>
3 #include <string.h>
5 // This tests that the suppression for the leak in setenv() works. See bug
6 // 188572.
8 int main(void)
10 char* val1 = "x";
11 char* val2 = "xx";
12 char* val3 = "xxx";
14 setenv("MYVAR", val1, /*overwrite*/0); // makes a copy which is later leaked
15 assert( 0 == strcmp(getenv("MYVAR"), val1) );
17 setenv("MYVAR", val2, /*overwrite*/1); // makes a copy which is later leaked
18 assert( 0 == strcmp(getenv("MYVAR"), val2) );
20 setenv("MYVAR", val3, /*overwrite*/0); // doesn't overwrite MYVAR=val2
21 assert( 0 == strcmp(getenv("MYVAR"), val2) );
23 putenv("MYVAR=xxxx"); // no leak for putenv()
24 assert( 0 == strcmp(getenv("MYVAR"), "xxxx") );
26 unsetenv("MYVAR");
27 assert( NULL == getenv("MYVAR") );
29 return 0;