title: SDL why create textures on the heap instead of stack
body: <p>So I've been reading over lazyfoos SDL2 tutorials and I was just curious how come all of the <code>SDL_Surface</code>/<code>SDL_textures</code> etc are created on the heap? I realize SDL itself was written in C and the functions accept/return pointers, but why not create the surface on the stack and pass a reference of it to the function? (Or dereference it when assigning)</p>
  
  <p>Hopefully I've been clear. Here's a code snippet to further try to explain:</p>
  
  <p>why this:</p>
  
  <pre><code>void pointer()
  {
      SDL_Surface *windowsurface;
      SDL_Surface *surface = SDL_LoadBMP("asdf.bmp");
      SDL_BlitSurface(surface, 0, windowsurface, 0);
  }
  </code></pre>
  
  <p>instead of this:</p>
  
  <pre><code>void stack()
  {
      SDL_Surface windowsurface;
      SDL_Surface surface = *(SDL_LoadBMP("asdf.bmp"));
      SDL_Blit(&amp;surface, 0, &amp;windowsurface, 0);
  }
  </code></pre>
  
  <p>If the latter is indeed possible, would you still need to call <code>SDL_FreeSurface</code>? If so this would ensure you won't leak any memory so I don't quite see the benefit of the former. </p>
  
  <p>Hopefully this all makes sense, I'm still a rookie when it comes to SDL</p>