title: VLC / libvlc free memory
body: <p>I have some trouble with releasing memory allocated by VLCs libvlc. (<a href="http://www.videolan.org/developers/vlc/doc/doxygen/html/index.html" rel="nofollow">http://www.videolan.org/developers/vlc/doc/doxygen/html/index.html</a>)</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;vlc/vlc.h&gt;
  
  int main(int argc, char* argv[])
  {
      libvlc_instance_t * inst;
  
      inst = libvlc_new (0, NULL);
  
      libvlc_release (inst);
  
      return 0;
  }
  </code></pre>
  
  <p>Compiled with: <code>gcc -o tvlc tvlc.c -lvlc</code></p>
  
  <p>Valgrind says, that there are still 32 non-freed bytes. But I don't know any other way to free the memory, consumed by vlc.</p>
  
  <p>My second problem is with freeing an array which I passed to the vlc-method <code>libvlc_media_new_path</code>.</p>
  
  <pre><code>#include &lt;string.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;vlc/vlc.h&gt;
  
  int main(int argc, char* argv[])
  {
      libvlc_instance_t * inst;
      libvlc_media_player_t *mp;
      libvlc_media_t *m;
  
      char *path = "/home/Musik/test.mp3";
      char songpath[ strlen(path) +1 ];
      memcpy(songpath, path, strlen(path) +1);
  
      inst = libvlc_new (0, NULL);
  
      m = libvlc_media_new_path (inst, songpath);
  
      mp = libvlc_media_player_new_from_media (m);
  
      libvlc_media_release (m);
  
      libvlc_media_player_release (mp);
  
      libvlc_release (inst);
  
      free(songpath);
  
      return 0;
  }
  </code></pre>
  
  <p>Compiled with: <code>gcc -o ttvlc ttvlc.c -lvlc</code></p>
  
  <p>As soon as I try to free the pointer <code>songpath</code>, the program crashes:</p>
  
  <blockquote>
    <p>invalid pointer: 0x00007fff4dd76f90</p>
  </blockquote>
  
  <p>If I do not free the memory, it won"t crash. Can anybody give me a hint what's wrong?</p>