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

Can you use realloc to resize an array? or do i have to do it the manual way??. At the moment realloc crashes wireshark but i may be using incorrectly

asked 05 Feb '13, 19:55

StealthUE's gravatar image

StealthUE
667713
accept rate: 100%


What do you mean by "array"? A C array defined as, say int foo[20] cannot be resized at all. C99 supports variable-length arrays, as do pre-C99 versions of GCC, but those arrays aren't resizable - the size is fixed at the time the array is allocated.

If you use malloc() to allocate an array at run time, you can use realloc() to resize it. If that's crashing, you might be using it wrong.

permanent link

answered 05 Feb '13, 20:21

Guy%20Harris's gravatar image

Guy Harris ♦♦
17.4k335196
accept rate: 19%

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:

×6
×4

question asked: 05 Feb '13, 19:55

question was seen: 1,319 times

last updated: 05 Feb '13, 20:21

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