This is the mail archive of the mailing list for the elfutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 0/4] Improve elfutils diagnostics

Hi -

On Thu, May 14, 2015 at 01:16:57PM +0200, Mark Wielaard wrote:
> [...]
> > How would such a list-of-strings be represented?  Considering that
> > this is C, and the list arity will vary, we'd be doing dynamic
> > allocation anyway, right?
> Less allocation is better than more, especially if there are situations
> where the extra allocations might not be used anyway.

Note that a single concatenated string involves one allocated block at
a time; an array or linked list containing structs and strings(!)
involves many more.  It suffers in terms of copying only.

> [...]  So the ideal way to represent it might be an array plus
> length of pairs typedef struct Dwfl_ErrDetail { int errno, const
> char *detail }.  [...]

That "char *detail;" brings its own memory allocation / lifetime
headaches.  In fact, since the elfutils library would have to strdup
those strings internally (since they can't be assumed to be static),
it's really not much better than just constructing the formatted
string in the first place.

- FChE

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]