Ethereal-dev: [Ethereal-dev] Q: conversation_add_proto_data() & friends

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Axel Schwenke <axel@xxxxxxxxx>
Date: Wed, 10 May 2006 12:43:24 +0200
Hi /all,

I'm adding connection state information to my dissector using the
conversation_*_proto_data() functions. Unfortunately there is no
documentation for those functions so I looked into other dissectors to
get an idea how to use them. Actually I looked into packet_rsync.c.

Now I have a few questions:

1. In packet_rsync.c conversation_add_proto_data() is called everytime
after having changed a member of the data structure. I guess this is an
error, because conversation_get_proto_data() delivers just a pointer to
the data structure, so all modifications are done in place. Correct?

2. I wonder how to deallocate memory that has been allocated for the
data structure. Clearly one can free() the pointer to my structure when
a conversation is dropped, but what happens if I use pointers in there?
Example:

struct conn_data {
  int foo;
  char* bar;
}

here foo can be deallocated but the content of *bar is lost.

3. How should I handle out of memory condition in my dissector?
Currently I use g_malloc() but I guess this is wrong.



mfg, XL
-- 
Axel Schwenke, Senior Software Developer
MySQL GmbH, Oberursel Germany, www.mysql.com

Are you MySQL certified?  www.mysql.com/certification

Attachment: signature.asc
Description: OpenPGP digital signature