Remove make_cleanup_value_free_to_mark
[deliverable/binutils-gdb.git] / gdb / guile / scm-type.c
index f2e7be3e4501e08b32ad15d131589d562c48c6ec..5c4490d5ffc1884980c06575aae53cf4aa803c3e 100644 (file)
@@ -576,10 +576,16 @@ gdbscm_type_tag (SCM self)
   type_smob *t_smob
     = tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
   struct type *type = t_smob->type;
+  const char *tagname = nullptr;
 
-  if (!TYPE_TAG_NAME (type))
+  if (TYPE_CODE (type) == TYPE_CODE_STRUCT
+      || TYPE_CODE (type) == TYPE_CODE_UNION
+      || TYPE_CODE (type) == TYPE_CODE_ENUM)
+    tagname = TYPE_NAME (type);
+
+  if (tagname == nullptr)
     return SCM_BOOL_F;
-  return gdbscm_scm_from_c_string (TYPE_TAG_NAME (type));
+  return gdbscm_scm_from_c_string (tagname);
 }
 
 /* (type-name <gdb:type>) -> string
@@ -971,7 +977,6 @@ gdbscm_type_field (SCM self, SCM field_scm)
   struct type *type = t_smob->type;
   char *field;
   int i;
-  struct cleanup *cleanups;
 
   SCM_ASSERT_TYPE (scm_is_string (field_scm), field_scm, SCM_ARG2, FUNC_NAME,
                   _("string"));
@@ -986,7 +991,6 @@ gdbscm_type_field (SCM self, SCM field_scm)
                               _(not_composite_error));
 
   field = gdbscm_scm_to_c_string (field_scm);
-  cleanups = make_cleanup (xfree, field);
 
   for (i = 0; i < TYPE_NFIELDS (type); i++)
     {
@@ -994,12 +998,12 @@ gdbscm_type_field (SCM self, SCM field_scm)
 
       if (t_field_name && (strcmp_iw (t_field_name, field) == 0))
        {
-           do_cleanups (cleanups);
-           return tyscm_make_field_smob (self, i);
+         xfree (field);
+         return tyscm_make_field_smob (self, i);
        }
     }
 
-  do_cleanups (cleanups);
+  xfree (field);
 
   gdbscm_out_of_range_error (FUNC_NAME, SCM_ARG1, field_scm,
                             _("Unknown field"));
@@ -1016,7 +1020,6 @@ gdbscm_type_has_field_p (SCM self, SCM field_scm)
   struct type *type = t_smob->type;
   char *field;
   int i;
-  struct cleanup *cleanups;
 
   SCM_ASSERT_TYPE (scm_is_string (field_scm), field_scm, SCM_ARG2, FUNC_NAME,
                   _("string"));
@@ -1031,7 +1034,6 @@ gdbscm_type_has_field_p (SCM self, SCM field_scm)
                               _(not_composite_error));
 
   field = gdbscm_scm_to_c_string (field_scm);
-  cleanups = make_cleanup (xfree, field);
 
   for (i = 0; i < TYPE_NFIELDS (type); i++)
     {
@@ -1039,12 +1041,12 @@ gdbscm_type_has_field_p (SCM self, SCM field_scm)
 
       if (t_field_name && (strcmp_iw (t_field_name, field) == 0))
        {
-           do_cleanups (cleanups);
-           return SCM_BOOL_T;
+         xfree (field);
+         return SCM_BOOL_T;
        }
     }
 
-  do_cleanups (cleanups);
+  xfree (field);
 
   return SCM_BOOL_F;
 }
This page took 0.025157 seconds and 4 git commands to generate.