title: how would the memory management work for the C pointer in ObjectiveC
body: <p>For the following code, essentially, we are calling C functions (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?</p>
  
  <p>.h</p>
  
  <pre><code>@interface MyObject : NSObject {
      X *pX;
  }
  </code></pre>
  
  <p>.m</p>
  
  <pre><code>// calling funca and get the value pX properly set
  if (funca(&amp;pX) != 0) {
      // error;
  }
  
  // use the pX returned from funca
  funcb(pX, ...);
  </code></pre>