Jump to content

TLM extension


Recommended Posts

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.

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...