]> git.jsancho.org Git - guile-irrlicht.git/blobdiff - src/video-driver.cpp
free strings previously allocated for conversions
[guile-irrlicht.git] / src / video-driver.cpp
index dd663e745d75e45b8d4c695d21e66baaa76c4a41..35491116ff13fcc1e039736c8e26a29456128dca 100644 (file)
@@ -28,7 +28,6 @@
 #include "rect.h"
 #include "vertex3d.h"
 #include "video-driver.h"
-#include "wchar.h"
 #include "wrapped.h"
 
 using namespace irr;
@@ -119,15 +118,17 @@ SCM
 IVideoDriver_getName (SCM video_driver)
 {
   video::IVideoDriver* driver = (video::IVideoDriver*) scm_to_irr_pointer (video_driver);
-  return scm_from_wide_char_string (driver->getName ());
+  return scm_from_utf32_string ((scm_t_wchar*) driver->getName ());
 }
 
 SCM
 IVideoDriver_getTexture (SCM video_driver,
                          SCM filename)
 {
+  char* cfilename = scm_to_utf8_string (filename);
   video::IVideoDriver* driver = (video::IVideoDriver*) scm_to_irr_pointer (video_driver);
-  video::ITexture* texture = driver->getTexture (scm_to_utf8_string (filename));
+  video::ITexture* texture = driver->getTexture (cfilename);
+  free (cfilename);
   return scm_from_pointer ((void*) texture, NULL);
 }
 
@@ -169,38 +170,43 @@ init_video_driver (void)
 video::E_TRANSFORMATION_STATE
 scm_to_transformation_state (SCM transformation_state)
 {
-  char* state = scm_to_utf8_string (scm_symbol_to_string (transformation_state));
-  if (!strcmp (state, "view"))
+  char* state_name = scm_to_utf8_string (scm_symbol_to_string (transformation_state));
+  video::E_TRANSFORMATION_STATE state;
+
+  if (!strcmp (state_name, "view"))
     {
-      return video::ETS_VIEW;
+      state = video::ETS_VIEW;
     }
-  else if (!strcmp (state, "world"))
+  else if (!strcmp (state_name, "world"))
     {
-      return video::ETS_WORLD;
+      state = video::ETS_WORLD;
     }
-  else if (!strcmp (state, "projection"))
+  else if (!strcmp (state_name, "projection"))
     {
-      return video::ETS_PROJECTION;
+      state = video::ETS_PROJECTION;
     }
-  else if (!strcmp (state, "texture0"))
+  else if (!strcmp (state_name, "texture0"))
     {
-      return video::ETS_TEXTURE_0;
+      state = video::ETS_TEXTURE_0;
     }
-  else if (!strcmp (state, "texture1"))
+  else if (!strcmp (state_name, "texture1"))
     {
-      return video::ETS_TEXTURE_1;
+      state = video::ETS_TEXTURE_1;
     }
-  else if (!strcmp (state, "texture2"))
+  else if (!strcmp (state_name, "texture2"))
     {
-      return video::ETS_TEXTURE_2;
+      state = video::ETS_TEXTURE_2;
     }
-  else if (!strcmp (state, "texture3"))
+  else if (!strcmp (state_name, "texture3"))
     {
-      return video::ETS_TEXTURE_3;
+      state = video::ETS_TEXTURE_3;
     }
   else
     {
       scm_error (scm_arg_type_key, NULL, "Wrong transformation state: ~S",
                  scm_list_1 (transformation_state), scm_list_1 (transformation_state));
     }
+
+  free (state_name);
+  return state;
 }