zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: Clint Adams <schizo@debian.org>
Cc: zsh-workers@sunsite.auc.dk
Subject: Re: PATCH: zasprintf
Date: Sun, 17 Sep 2000 16:13:56 +0000	[thread overview]
Message-ID: <1000917161356.ZM19396@candle.brasslantern.com> (raw)
In-Reply-To: <20000917110403.A4270@dman.com>

On Sep 17, 11:04am, Clint Adams wrote:
} Subject: Re: PATCH: zasprintf
}
} > I don't believe there's any use zsh could make of asprintf()
} > that isn't better solved another way.
} 
} If by "better" you mean "avoiding asprintf and dealing with a specialized
} case."

I do, mostly because I don't think there are very many specialized cases.
There are 96 uses of sprintf() in zsh, nearly all of them used to convert
integers to strings (which hardly requires a dynamically allocated buffer).
Several of the remaining ones are used for path concatenation.  None have
particularly complex format strings.

I simply think that asprintf() is over-generalized.

} > I don't have any such confidence that asprintf() would be cleaner or more
} > efficient than, say, a realloc'ing version of tricat()
} 
} Why, other than portability?

For one thing, because it can't realloc().  That means that if you use it
in a loop, you have to allocate and free the buffer every time around,
even if you're always writing approximately the same size string.

For another thing:

} Speaking of the real tricat, this eliminates bin_dot's dependence on
} PATH_MAX:

This is a case where a zsh-heap-allocating version of tricat() would be
slightly preferable to a permanent-heap-allocating version.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


  reply	other threads:[~2000-09-17 16:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-09-16 18:53 Clint Adams
2000-09-17  0:47 ` Bart Schaefer
2000-09-17  1:10   ` PATH_MAX again Bart Schaefer
2000-09-17  4:25   ` PATCH: zasprintf Clint Adams
2000-09-17  5:37     ` Bart Schaefer
2000-09-17 15:04       ` Clint Adams
2000-09-17 16:13         ` Bart Schaefer [this message]
2000-09-17 16:43           ` Clint Adams
2000-09-17 12:21   ` Zefram
2000-09-18 13:28 ` Andrej Borsenkow

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=1000917161356.ZM19396@candle.brasslantern.com \
    --to=schaefer@candle.brasslantern.com \
    --cc=schizo@debian.org \
    --cc=zsh-workers@sunsite.auc.dk \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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 NNTP newsgroup(s).