Debian Codegraph @

nsprpub/pr/tests/freeif.c

raw
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 printf("FAIL\n");
20 exit(1);
21 }
22
23 int main(int argc, char** argv) {
24 int foo = 1;
25 char* ptr = NULL;
26
27 /* this fails to compile with the old definition of PR_DELETE */
28 if (foo) {
29 PR_DELETE(ptr);
30 } else {
31 Noop();
32 }
33
34 /* this nests incorrectly with the old definition of PR_FREEIF */
35 if (foo) {
36 PR_FREEIF(ptr);
37 } else {
38 Fail();
39 }
40
41 printf("PASS\n");
42 return 0;
43 }