title: Does shared_ptr free memory allocated on the heap?
body: <p>So in my job I don't have access to the full std library because....just because (corporate nonsense reasons).  I can't use unique_ptr but I have access to shared_ptr and I'm working with c++11.  So...</p>
  
  <p>I am using a pre-existing (internal) library function that gets data for me and returns it via a raw point (lets say uint8_t*).  And I am want to store this data in my class as a shared_ptr.</p>
  
  <p>According to <a href="https://stackoverflow.com/questions/12713004/will-a-shared-ptr-automatically-free-up-memory">Will a shared_ptr automatically free up memory?</a></p>
  
  <p>and <a href="http://herbsutter.com/2013/05/29/gotw-89-solution-smart-pointers/" rel="nofollow noreferrer">http://herbsutter.com/2013/05/29/gotw-89-solution-smart-pointers/</a></p>
  
  <p>it appears that if I allocate memory on the heap and store this in a shared_ptr, the smart pointer should deallocate the memory (of uint8_t* data) for me.  Is this true?  Any links to literature would help.  Also, from these links it seems that I can't use make_shared because I am "adopting a raw pointer from somewhere else."</p>
  
  <pre><code>class myClass
  {
  public:
      shared_ptr&lt;uint8_t&gt; iv_data;
      // rest of class
  };
  </code></pre>
  
  <h2>other function scope</h2>
  
  <pre><code>data_size = getDataSize(...);  // legacy internal function
  uint8_t* data = new uint8_t[data_size];
  getData(data, data_size); // legacy internal function
  
  myClass object;
  object.iv_spd_data = std::shared_ptr&lt;uint8_t&gt;(l_spd_data);
  
  // if scope ends here will I get a memory leak for not freeing data
  </code></pre>