DS1701 Posted April 3, 2019 Report Share Posted April 3, 2019 I read some source code. class TlmExtension : public tlm_extension<TlmExtension> { ... }; void setExtension(tlm::tlm_generic_payload &in, tlm::tlm_generic_payload &out) { TlmExtension *input = (TlmExtension *)0; TlmExtension *output = new TlmExtension; in.get_extension(input); if (input != NULL) { output->setNum(input->getNum()); output->setChannel(input->getChannel()); out.set_extension(output); } } I think above code is wrong. Because of when exit setExtension function. We cant delete object create by new operator (output ) How to resolve this problem? Thanks. BR. Quote Link to comment Share on other sites More sharing options...
Eyck Posted April 3, 2019 Report Share Posted April 3, 2019 Actually this is done in the desrtuctor of the tlm_generic_payload. This part calls for all extensions the free() function. So if out is handled properly destroyed all extensions are destroyed as well. The other option is to call free_all_extensions() explicitly which also calls free() for all extensions as well as for auto extensions (those might be registered when a memory manager for the generic payload is used, usually in AT style modelling using the non-blocking interfaces). HTH DS1701 1 Quote Link to comment Share on other sites More sharing options...
DS1701 Posted April 4, 2019 Author Report Share Posted April 4, 2019 Thank @Eyck As your comment, my understand that 1. It is done in the destructor of the the tlm_generic_payload ( both AT and LT style ) 2. The other option is to call free_all_extensions() after transaction completed ( only AT style ) Is it correct? Thanks. Quote Link to comment Share on other sites More sharing options...
Eyck Posted April 5, 2019 Report Share Posted April 5, 2019 In principle yes, but I would not call it LT or AT as it depends on hte use of a memory manager which can be used in any case. Cheers Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.