diff --git a/plugins/ruby/ruby.cpp b/plugins/ruby/ruby.cpp index 33477d56e..17db1eb21 100644 --- a/plugins/ruby/ruby.cpp +++ b/plugins/ruby/ruby.cpp @@ -778,9 +778,7 @@ static VALUE rb_dfmemory_stlstring_delete(VALUE self, VALUE addr) } static VALUE rb_dfmemory_stlstring_init(VALUE self, VALUE addr) { - // XXX THIS IS TERRIBLE - std::string *ptr = new std::string; - memcpy((void*)rb_num2ulong(addr), (void*)ptr, sizeof(*ptr)); + new((void*)rb_num2ulong(addr)) std::string(); return Qtrue; } static VALUE rb_dfmemory_read_stlstring(VALUE self, VALUE addr) @@ -812,8 +810,7 @@ static VALUE rb_dfmemory_vec_delete(VALUE self, VALUE addr) } static VALUE rb_dfmemory_vec_init(VALUE self, VALUE addr) { - std::vector *ptr = new std::vector; - memcpy((void*)rb_num2ulong(addr), (void*)ptr, sizeof(*ptr)); + new((void*)rb_num2ulong(addr)) std::vector(); return Qtrue; } // vector @@ -903,8 +900,7 @@ static VALUE rb_dfmemory_vecbool_delete(VALUE self, VALUE addr) } static VALUE rb_dfmemory_vecbool_init(VALUE self, VALUE addr) { - std::vector *ptr = new std::vector; - memcpy((void*)rb_num2ulong(addr), (void*)ptr, sizeof(*ptr)); + new((void*)rb_num2ulong(addr)) std::vector(); return Qtrue; } static VALUE rb_dfmemory_vecbool_length(VALUE self, VALUE addr)