public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Frank Ch. Eigler <fche@redhat.com>
To: elfutils-devel@lists.fedorahosted.org
Subject: Re: [PATCH 0/4] Improve elfutils diagnostics
Date: Fri, 15 May 2015 12:10:14 -0400	[thread overview]
Message-ID: <20150515161014.GE19346@redhat.com> (raw)
In-Reply-To: 20150514111657.GD26243@blokker.redhat.com

[-- Attachment #1: Type: text/plain, Size: 1066 bytes --]

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

             reply	other threads:[~2015-05-15 16:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-15 16:10 Frank Ch. Eigler [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-05-15 21:21 Mark Wielaard
2015-05-14 11:46 Mark Wielaard
2015-05-14 11:16 Mark Wielaard
2015-05-13 18:44 Jonathan Lebon
2015-05-13 17:31 Frank Ch. Eigler
2015-05-13 16:28 Mark Wielaard
2015-05-11 19:38 Jonathan Lebon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150515161014.GE19346@redhat.com \
    --to=fche@redhat.com \
    --cc=elfutils-devel@lists.fedorahosted.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).