You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you are wrapping a C structure you can use mrb_malloc so there is no issue but how would you do it for a C++ object ? If I use new it won't be allocated on the mruby stack and if I use mrb_malloc the C++ specifc stuff won't be done...
In c I do it like this where manager_state is my c structure:
You can write your own new and delete functions that will be executed instead of the standard implementation. In your implementation use mrb_malloc and mrb_free.
I'm using "placement new" to create instance of C++ Class in mruby-arduino mrbgem.
Placement new allows you to use specific address (ex. memory area obtained by mrb_malloc), for instance.
When you are wrapping a C structure you can use mrb_malloc so there is no issue but how would you do it for a C++ object ? If I use new it won't be allocated on the mruby stack and if I use mrb_malloc the C++ specifc stuff won't be done...
In c I do it like this where manager_state is my c structure:
I would prefer avoiding C++ entirely but that is not an option here.
The text was updated successfully, but these errors were encountered: