From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============1607444879016934441==" MIME-Version: 1.0 From: Mark Wielaard To: elfutils-devel@lists.fedorahosted.org Subject: Re: [PATCH 0/4] Improve elfutils diagnostics Date: Thu, 14 May 2015 13:16:57 +0200 Message-ID: <20150514111657.GD26243@blokker.redhat.com> In-Reply-To: 20150513173100.GC11588@redhat.com --===============1607444879016934441== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable On Wed, May 13, 2015 at 01:31:00PM -0400, Frank Ch. Eigler wrote: > > One implementation detail that I like to see changed is to make the > > details errmsg a list of strings instead of one big string (and > > similarly for dw_tried_paths). [...] > = > 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, I am mostly concerned by the asprintf string concats. Those seem to be done for two reasons that I like to see split out. They concat because they want to represent the errno (string) and an extra argument (e.g. file not found plus file name). In which case I think it is better to store that as two separate items, the errno and the detail, so no extra string needs to be constructed, unless the user want to. And to add compound failures together. In that case I think an array or list of failures (errno plus detail pairs) would be better. So the ideal way to represent it might be an array plus length of pairs typedef struct Dwfl_ErrDetail { int errno, const char *detail }. Then the array can be preallocated and realloced when necessary. Cheers, Mark --===============1607444879016934441==--