Author: Wim Lavrijsen <[email protected]>
Branch: reflex-support
Changeset: r63074:7159a9b97251
Date: 2013-04-05 16:18 -0700
http://bitbucket.org/pypy/pypy/changeset/7159a9b97251/

Log:    stubs use placement new

diff --git a/pypy/module/cppyy/src/reflexcwrapper.cxx 
b/pypy/module/cppyy/src/reflexcwrapper.cxx
--- a/pypy/module/cppyy/src/reflexcwrapper.cxx
+++ b/pypy/module/cppyy/src/reflexcwrapper.cxx
@@ -170,11 +170,13 @@
 }
 
 char* cppyy_call_s(cppyy_method_t method, cppyy_object_t self, int nargs, 
void* args) {
-    std::string result("");
+    std::string* cppresult = (std::string*)malloc(sizeof(std::string));
     std::vector<void*> arguments = build_args(nargs, args);
     Reflex::StubFunction stub = (Reflex::StubFunction)method;
-    stub(&result, (void*)self, arguments, NULL /* stub context */);
-    return cppstring_to_cstring(result);
+    stub(cppresult, (void*)self, arguments, NULL /* stub context */);
+    char* cstr = cppstring_to_cstring(*cppresult);
+    delete cppresult;         // the stub will have performed a placement-new
+    return cstr;
 }
 
 cppyy_object_t cppyy_constructor(cppyy_method_t method, cppyy_type_t handle, 
int nargs, void* args) {
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to