struct {
    float f;
} Foo;

struct {
    Foo *foo;
} Bar;

Foo *psFooAlloc () {
    Foo *foo = (Foo *) psAlloc (1);
    return (foo);
}

psFooFree (Foo *foo) {
    psFree (foo);
    return;
}

Bar *psBarAlloc () {
    Bar *bar = (Bar *) psAlloc (1);
    bar[0].foo = NULL;
    return (bar);
}

psBarFree (Bar *bar) {
    psFooFree (bar[0].foo);
    psFree (bar);
    return;
}

Bar *psBarSet (Foo *foo) {
    Bar *bar = NULL;
    bar = psBarAlloc ();
    bar[0].foo = foo;
    IncrRef (foo);
}

main () {

    Foo *foo = NULL;
    Bar *bar = NULL;

    foo = psFooAlloc ();		// Nref(foo) = 1
    bar = psBarSet (foo);		// Nref(foo) = 2
    psFooFree (foo);			// Nref(foo) = 1
    psBarFree (bar);			// Nref(foo) = 0
}
