summaryrefslogtreecommitdiff
path: root/nsprpub/pr/tests/freeif.c
blob: 1d38d0e31aa1302c664dce3a0b8a25df426bdb70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/*
 * A test to see if the macros PR_DELETE and PR_FREEIF are
 * properly defined.  (See Bugzilla bug #39110.)
 */

#include "nspr.h"

#include <stdio.h>
#include <stdlib.h>

static void Noop(void) { }

static void Fail(void)
{
    printf("FAIL\n");
    exit(1);
}

int main(int argc, char **argv)
{
    int foo = 1;
    char *ptr = NULL;

    /* this fails to compile with the old definition of PR_DELETE */
    if (foo) {
        PR_DELETE(ptr);
    }
    else {
        Noop();
    }

    /* this nests incorrectly with the old definition of PR_FREEIF */
    if (foo) {
        PR_FREEIF(ptr);
    }
    else {
        Fail();
    }

    printf("PASS\n");
    return 0;
}