[Bro] deleting objects passed to BiF event handlers
jamesfhook at gmail.com
Tue Oct 22 00:24:53 PDT 2013
Thanks Jon, that makes a sense.
P.S.: the example code was pretty good for getting up and running very
quickly and demonstrating a lot of the marshaling of bro data types. There
were a couple of bits I had to change for Bro2.2Beta.
- BroTypePtr:: is now just BroType
- bro.init is now init-bare.bro
Very seldom I get these things to work so quickly though :-)
On 21 October 2013 15:50, Siwek, Jonathan Luke <jsiwek at illinois.edu> wrote:
> On Oct 19, 2013, at 6:35 PM, James Hook <jamesfhook at gmail.com> wrote:
> > I've just been working through the example of creating built in
> functions http://www.bro.org/development/howtos/bif-doc/example.html
> > I have a quick question about what the design pattern should be for
> deleting objects created and passed to the firing event handler. For
> example, in the code below, is deleting the msg pointer likely to cause
> problems to QueueEvent?
> Yes (it will probably cause a double-free when there's a bif_test_event
> handler). EventMgr::QueueEvent takes ownership of the val_list and a
> single reference count to any elements in it.
> > Or does the StringVal class do something clever behind the scenes to
> stop memory leaks?
> No. I'll fix the example code in the docs to better demonstrate correct
> memory management -- which probably the best way is to just not allocate a
> Val or val_list unless it's known it's going to get passed to
> - Jon
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Bro