+2017-10-08 Tom Tromey <tom@tromey.com>
+
+ * utils.h (make_cleanup_value_free): Remove.
+ * utils.c (do_value_free, struct cleanup): Remove.
+ * dwarf2loc.c (dwarf2_evaluate_loc_desc_full) <DWARF_VALUE_STACK>:
+ Use gdb_value_up.
+ * value.h (struct value_deleter): New.
+ (gdb_value_up): New typedef.
+
2017-10-08 Tom Tromey <tom@tromey.com>
* symtab.c (free_search_symbols, do_free_search_symbols_cleanup)
size_t len = TYPE_LENGTH (subobj_type);
size_t max = TYPE_LENGTH (type);
struct gdbarch *objfile_gdbarch = get_objfile_arch (objfile);
- struct cleanup *cleanup;
if (subobj_byte_offset + len > max)
invalid_synthetic_pointer ();
below. */
value_incref (value);
free_values.free_to_mark ();
- cleanup = make_cleanup_value_free (value);
+ gdb_value_up value_holder (value);
retval = allocate_value (subobj_type);
memcpy (value_contents_raw (retval),
value_contents_all (value) + subobj_byte_offset, len);
-
- do_cleanups (cleanup);
}
break;
return make_cleanup (do_value_free_to_mark, mark);
}
-/* Helper for make_cleanup_value_free. */
-
-static void
-do_value_free (void *value)
-{
- value_free ((struct value *) value);
-}
-
-/* Free VALUE. */
-
-struct cleanup *
-make_cleanup_value_free (struct value *value)
-{
- return make_cleanup (do_value_free, value);
-}
-
/* This function is useful for cleanups.
Do
extern struct cleanup *make_cleanup_unpush_target (struct target_ops *ops);
extern struct cleanup *make_cleanup_value_free_to_mark (struct value *);
-extern struct cleanup *make_cleanup_value_free (struct value *);
/* A deleter for a hash table. */
struct htab_deleter
extern void value_free (struct value *val);
+/* A free policy class to interface std::unique_ptr with
+ value_free. */
+
+struct value_deleter
+{
+ void operator() (struct value *value) const
+ {
+ value_free (value);
+ }
+};
+
+/* A unique pointer to a struct value. */
+
+typedef std::unique_ptr<struct value, value_deleter> gdb_value_up;
+
extern void free_all_values (void);
extern void free_value_chain (struct value *v);