|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 /* |
|
7 * A test to see if the macros PR_DELETE and PR_FREEIF are |
|
8 * properly defined. (See Bugzilla bug #39110.) |
|
9 */ |
|
10 |
|
11 #include "nspr.h" |
|
12 |
|
13 #include <stdio.h> |
|
14 #include <stdlib.h> |
|
15 |
|
16 static void Noop(void) { } |
|
17 |
|
18 static void Fail(void) |
|
19 { |
|
20 printf("FAIL\n"); |
|
21 exit(1); |
|
22 } |
|
23 |
|
24 int main(int argc, char **argv) |
|
25 { |
|
26 int foo = 1; |
|
27 char *ptr = NULL; |
|
28 |
|
29 /* this fails to compile with the old definition of PR_DELETE */ |
|
30 if (foo) |
|
31 PR_DELETE(ptr); |
|
32 else |
|
33 Noop(); |
|
34 |
|
35 /* this nests incorrectly with the old definition of PR_FREEIF */ |
|
36 if (foo) |
|
37 PR_FREEIF(ptr); |
|
38 else |
|
39 Fail(); |
|
40 |
|
41 printf("PASS\n"); |
|
42 return 0; |
|
43 } |