how would the memory management work for the C pointer in ObjectiveC
===

For the following code, essentially, we are calling C funtions (funca and funcb) in ObjectiveC and using the C pointer pX. For some reason, we hit EXC_BAD_ACCESS on calling funcb, we figured that it might be related to pX being released or some other memory problems. So the question is, what could go wrong here? If it's really because that pX getting released early, how could we fix it? what's the general practice of doing C inside ObjectiveC, just like this scenario?

.h

    @interface MyObject : NSObject {
        X *pX;
    }

.m

    // calling funca and get the value pX properly set
    if (funca(&pX) != 0) {
        // error;
    }

    // use the pX returned from funca
    funcb(pX, ...);