[GRASS-dev] clean_temp rewritten

Glynn Clements glynn at gclements.plus.com
Mon Jun 26 07:43:23 EDT 2006


Hamish wrote:

> > > Changing the code to use G_asprintf() instead is one alternative
> > > (although G_asprintf() uses a temporary file on systems which lack
> > > asprintf()).
> 
> I've disliked G_asprintf() due to this inefficiency, but last month
> Glynn noted that most file systems won't bother to write to disk if
> the file is removed before the disk buffer is flushed, so maybe it isn't
> so bad.

It's still likely to involve a number of syscalls, whereas asprintf()
and snprintf() typically won't require any (asprintf() might require
one syscall if malloc() needs to enlarge the heap).

A more practical asprintf() implementation would call snprintf(),
using successively larger buffers in the case of failure. Of course,
that requires that you have snprintf() in the first place.

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list