diff options
-rw-r--r-- | src/library_sdl.js | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/library_sdl.js b/src/library_sdl.js index c2e29fab..04ccc79a 100644 --- a/src/library_sdl.js +++ b/src/library_sdl.js @@ -2013,19 +2013,22 @@ var LibrarySDL = { SDL_InitSubSystem: function(flags) { return 0 }, SDL_RWFromConstMem: function(mem, size) { - var id = SDL.rwops.length - SDL.rwops.push( {'bytes': mem, 'count': size} ); + var id = SDL.rwops.length; // TODO: recycle ids when they are null + SDL.rwops.push( { 'bytes': mem, 'count': size } ); return id; }, SDL_RWFromFile: function(filename, mode) { - var id = SDL.rwops.length - SDL.rwops.push( {'filename': filename} ); + var id = SDL.rwops.length; // TODO: recycle ids when they are null + SDL.rwops.push( { 'filename': filename } ); return id; }, SDL_FreeRW: function(rwopsID) { SDL.rwops[rwopsID] = null; + while (SDL.rwops.length > 0 && SDL.rwops[SDL.rwops.length-1] === null) { + SDL.rwops.pop(); + } }, SDL_EnableUNICODE: function(on) { |