title: Linux C/C++ allocate/deallocate memory in dynamic library
body: <p>I have to split my application into several logical modules.</p>
  
  <p><code>mainapp</code>:</p>
  
  <ul>
  <li><code>module1.so</code></li>
  <li><code>module2.so</code></li>
  <li><code>module3.so</code></li>
  <li>and so on</li>
  </ul>
  
  <p>Where each module is an <code>*.so</code> library, which will be loaded during runtime.</p>
  
  <p>Each module shares the same interface and will return some array of data. For example:</p>
  
  <p><code>int *ptr = module1-&gt;getIntData();</code></p>
  
  <p>Is it OK, to free/delete this memory on <code>mainapp</code> side?</p>
  
  <pre><code>int *ptr = module1-&gt;getIntData();
  delete ptr; //(or free(ptr))
  </code></pre>
  
  <p>What about a malloc/free implementations. Is it possible, that library will use another one then mainapp?</p>