Hi Collin,

On 2026-03-11T10:42:22+0100, Bruno Haible wrote:
> Collin Funk wrote:
> > The asprintf function allows you to get the length of the resulting
> > string without calling strlen afterwards.

strlen(3) after malloc(3) + 2x snprintf(3) should be a non-issue.
strlen(3) is orders of magnitude faster than what asprintf(3) does.
I expect it won't be something that can be measured.  Plus, most of the
time you don't even need the length.


Have a lovely day!
Alex

> 
> And this, together with the return type of 'int', forces programs to
> check for NULL / EOVERFLOW results even for trivial format strings like
> "%s%s".
> 
> If properly designed, 'asprintf' should have changed its return type
> to ssize_t, like read() and write() did.
> 
> Bruno
> 
> 
> 

-- 
<https://www.alejandro-colomar.es>

Attachment: signature.asc
Description: PGP signature

Reply via email to