Wireshark-dev: Re: [Wireshark-dev] Column data memory allocation - excessive?
From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Sun, 02 Mar 2008 14:44:21 -0800
Stephen Fisher wrote:
One place where there are a lot of calls to the unsafe strcpy() is epan/column-utils.c. However, before replacing them with g_strpcpy(), I wanted to ask if there is any reason we can't start using dynamic memory allocation in those places (as Guy recently suggested) instead of g_strlcpy()?

I'm not sure I'd suggested that - I've mainly been concerned about the memory allocation internal to GTK+ for the column displays, rather than stuff Wireshark itself allocates.

We are allocating full field widths worth of memory for every column (256 bytes each) plus the info column (4096 bytes each) for every row in the build_column_format_array() function (in epan/column.c) ahead of time and then strcpy() data into them.

For every row? I might be misremembering, but I think only one set of column string buffers are allocated at start-up time, and those buffers are reused.