]> git.jsancho.org Git - guile-irrlicht.git/blobdiff - src/material-types.cpp
free strings previously allocated for conversions
[guile-irrlicht.git] / src / material-types.cpp
index 5faad7374f1fbc42879f9a1d60ccfb811f5c5947..eddb4cfe8210fe214f1b7020d9023d1f3361e186 100644 (file)
@@ -28,106 +28,111 @@ using namespace irr;
 video::E_MATERIAL_TYPE
 scm_to_material_type (SCM material_type)
 {
-  char* type = scm_to_utf8_string (scm_symbol_to_string (material_type));
-  if (!strcmp (type, "solid"))
+  char* type_name = scm_to_utf8_string (scm_symbol_to_string (material_type));
+  video::E_MATERIAL_TYPE type;
+
+  if (!strcmp (type_name, "solid"))
     {
-      return video::EMT_SOLID;
+      type = video::EMT_SOLID;
     }
-  else if (!strcmp (type, "solid-2-layer"))
+  else if (!strcmp (type_name, "solid-2-layer"))
     {
-      return video::EMT_SOLID_2_LAYER;
+      type = video::EMT_SOLID_2_LAYER;
     }
-  else if (!strcmp (type, "lightmap"))
+  else if (!strcmp (type_name, "lightmap"))
     {
-      return video::EMT_LIGHTMAP;
+      type = video::EMT_LIGHTMAP;
     }
-  else if (!strcmp (type, "lightmap-add"))
+  else if (!strcmp (type_name, "lightmap-add"))
     {
-      return video::EMT_LIGHTMAP_ADD;
+      type = video::EMT_LIGHTMAP_ADD;
     }
-  else if (!strcmp (type, "lightmap-m2"))
+  else if (!strcmp (type_name, "lightmap-m2"))
     {
-      return video::EMT_LIGHTMAP_M2;
+      type = video::EMT_LIGHTMAP_M2;
     }
-  else if (!strcmp (type, "lightmap-m4"))
+  else if (!strcmp (type_name, "lightmap-m4"))
     {
-      return video::EMT_LIGHTMAP_M4;
+      type = video::EMT_LIGHTMAP_M4;
     }
-  else if (!strcmp (type, "lightmap-lighting"))
+  else if (!strcmp (type_name, "lightmap-lighting"))
     {
-      return video::EMT_LIGHTMAP_LIGHTING;
+      type = video::EMT_LIGHTMAP_LIGHTING;
     }
-  else if (!strcmp (type, "lightmap-lighting-m2"))
+  else if (!strcmp (type_name, "lightmap-lighting-m2"))
     {
-      return video::EMT_LIGHTMAP_LIGHTING_M2;
+      type = video::EMT_LIGHTMAP_LIGHTING_M2;
     }
-  else if (!strcmp (type, "lightmap-lighting-m4"))
+  else if (!strcmp (type_name, "lightmap-lighting-m4"))
     {
-      return video::EMT_LIGHTMAP_LIGHTING_M4;
+      type = video::EMT_LIGHTMAP_LIGHTING_M4;
     }
-  else if (!strcmp (type, "detail-map"))
+  else if (!strcmp (type_name, "detail-map"))
     {
-      return video::EMT_DETAIL_MAP;
+      type = video::EMT_DETAIL_MAP;
     }
-  else if (!strcmp (type, "sphere-map"))
+  else if (!strcmp (type_name, "sphere-map"))
     {
-      return video::EMT_SPHERE_MAP;
+      type = video::EMT_SPHERE_MAP;
     }
-  else if (!strcmp (type, "reflection-2-layer"))
+  else if (!strcmp (type_name, "reflection-2-layer"))
     {
-      return video::EMT_REFLECTION_2_LAYER;
+      type = video::EMT_REFLECTION_2_LAYER;
     }
-  else if (!strcmp (type, "transparent-add-color"))
+  else if (!strcmp (type_name, "transparent-add-color"))
     {
-      return video::EMT_TRANSPARENT_ADD_COLOR;
+      type = video::EMT_TRANSPARENT_ADD_COLOR;
     }
-  else if (!strcmp (type, "transparent-alpha-channel"))
+  else if (!strcmp (type_name, "transparent-alpha-channel"))
     {
-      return video::EMT_TRANSPARENT_ALPHA_CHANNEL;
+      type = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
     }
-  else if (!strcmp (type, "transparent-alpha-channel-ref"))
+  else if (!strcmp (type_name, "transparent-alpha-channel-ref"))
     {
-      return video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
+      type = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
     }
-  else if (!strcmp (type, "transparent-vertex-alpha"))
+  else if (!strcmp (type_name, "transparent-vertex-alpha"))
     {
-      return video::EMT_TRANSPARENT_VERTEX_ALPHA;
+      type = video::EMT_TRANSPARENT_VERTEX_ALPHA;
     }
-  else if (!strcmp (type, "transparent-reflection-2-layer"))
+  else if (!strcmp (type_name, "transparent-reflection-2-layer"))
     {
-      return video::EMT_TRANSPARENT_REFLECTION_2_LAYER;
+      type = video::EMT_TRANSPARENT_REFLECTION_2_LAYER;
     }
-  else if (!strcmp (type, "normal-map-solid"))
+  else if (!strcmp (type_name, "normal-map-solid"))
     {
-      return video::EMT_NORMAL_MAP_SOLID;
+      type = video::EMT_NORMAL_MAP_SOLID;
     }
-  else if (!strcmp (type, "normal-map-transparent-add-color"))
+  else if (!strcmp (type_name, "normal-map-transparent-add-color"))
     {
-      return video::EMT_NORMAL_MAP_TRANSPARENT_ADD_COLOR;
+      type = video::EMT_NORMAL_MAP_TRANSPARENT_ADD_COLOR;
     }
-  else if (!strcmp (type, "normal-map-transparent-vertex-alpha"))
+  else if (!strcmp (type_name, "normal-map-transparent-vertex-alpha"))
     {
-      return video::EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA;
+      type = video::EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA;
     }
-  else if (!strcmp (type, "parallax-map-solid"))
+  else if (!strcmp (type_name, "parallax-map-solid"))
     {
-      return video::EMT_PARALLAX_MAP_SOLID;
+      type = video::EMT_PARALLAX_MAP_SOLID;
     }
-  else if (!strcmp (type, "parallax-map-transparent-add-color"))
+  else if (!strcmp (type_name, "parallax-map-transparent-add-color"))
     {
-      return video::EMT_PARALLAX_MAP_TRANSPARENT_ADD_COLOR;
+      type = video::EMT_PARALLAX_MAP_TRANSPARENT_ADD_COLOR;
     }
-  else if (!strcmp (type, "parallax-map-transparent-vertex-alpha"))
+  else if (!strcmp (type_name, "parallax-map-transparent-vertex-alpha"))
     {
-      return video::EMT_PARALLAX_MAP_TRANSPARENT_VERTEX_ALPHA;
+      type = video::EMT_PARALLAX_MAP_TRANSPARENT_VERTEX_ALPHA;
     }
-  else if (!strcmp (type, "onetexture-blend"))
+  else if (!strcmp (type_name, "onetexture-blend"))
     {
-      return video::EMT_ONETEXTURE_BLEND;
+      type = video::EMT_ONETEXTURE_BLEND;
     }
   else
     {
       scm_error (scm_arg_type_key, NULL, "Wrong material type: ~S",
                  scm_list_1 (material_type), scm_list_1 (material_type));
     }
+
+  free (type_name);
+  return type;
 }