This is our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

In my old plugin code(1.6), the following lines of codes has been used inside proto_register_myPlugin Routine to initialize Array to Zero. I know that se_alloc is invalid now and wmem_alloc should be used. I have tried different ways. It just isn't working. Could someone please help me? Thanks

msc_to_cmd_database = (void*) se_alloc(255 * (sizeof(proto_tree) + 1));
memset(msc_to_cmd_database, 0, 255 * (sizeof(proto_tree) + 1));

(in .h file _>)
 static struct msc_to_cmd_relation_struct {
    guint8 ife_command;
 }*msc_to_cmd_database;

asked 13 Feb '17, 04:43

xaheen's gravatar image

xaheen
71141519
accept rate: 50%

edited 13 Feb '17, 09:37

Guy%20Harris's gravatar image

Guy Harris ♦♦
17.4k335196

Could you please clarify what is not working exactly? Are you triggering an assert because you are not using the right memory scope?

(13 Feb '17, 06:35) Pascal Quantin

@Pascal Quantin I am upgrading the dissector for wireshark 2.2 I am supposed to use wmem, which I have used but it is not compiling and not even showing any error. What could be the wmem_alloc Version for the above code. Thanks for your Response

(13 Feb '17, 06:43) xaheen

Give a try to:

msc_to_cmd_database = (struct msc_to_cmd_relation_struct*) wmem_alloc0(wmem_epan_scope(), 255 * (sizeof(proto_tree) + 1));

But was this memory freed somewhere else in the code?

permanent link

answered 13 Feb '17, 07:12

Pascal%20Quantin's gravatar image

Pascal Quantin
5.5k1060
accept rate: 30%

@Pascal Quantin wow! it worked! thanks. No, I havent freed the Memory. how do I do it?

(13 Feb '17, 07:23) xaheen

If it is not required to free the memory in your plugin, why allocate it dynamically and not define the array once for all?

(13 Feb '17, 07:43) Pascal Quantin
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×637
×33
×7
×2

question asked: 13 Feb '17, 04:43

question was seen: 587 times

last updated: 13 Feb '17, 09:37

p​o​w​e​r​e​d by O​S​Q​A