Deutsch   English   Français   Italiano  
<103cvnu$1jvc7$5@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: Lawrence D'Oliveiro <ldo@nz.invalid>
Newsgroups: comp.os.vms
Subject: Re: FreeTDS port to VMS V9.x on x86?
Date: Tue, 24 Jun 2025 01:41:18 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <103cvnu$1jvc7$5@dont-email.me>
References: <101n7gq$4m9b$1@dont-email.me>
	<683f3086$0$693$14726298@news.sunsite.dk> <101ncau$57on$1@dont-email.me>
	<101nqij$9edo$1@dont-email.me> <101sb4a$1ioac$1@dont-email.me>
	<101shm9$1l3ag$1@dont-email.me> <101skdr$1lvhe$1@dont-email.me>
	<101t1fh$1op7a$1@dont-email.me> <101tglm$1s66m$1@dont-email.me>
	<101uodt$28rq1$1@dont-email.me> <101uuno$29494$1@dont-email.me>
	<101v0kt$2at4q$1@dont-email.me> <101v0s2$29494$2@dont-email.me>
	<101v1b2$29494$3@dont-email.me> <103ckn2$1hqm7$1@dont-email.me>
	<103cqrl$1j6rb$1@dont-email.me> <103crvv$1ip4g$11@dont-email.me>
	<103cs5l$1j6rb$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 24 Jun 2025 03:41:19 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="79e909dd4dfe24cbed6fb801abc04d71";
	logging-data="1703303"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/WUoDYxTMd+pTT28cVuG7r"
User-Agent: Pan/0.162 (Pokrosvk)
Cancel-Lock: sha1:aXJv4sXh9cMBBBUrjL2rW0MDmSE=

On Mon, 23 Jun 2025 20:40:21 -0400, Arne Vajhøj wrote:

> On 6/23/2025 8:37 PM, Lawrence D'Oliveiro wrote:
>>
>> What a dumb way to do it. Using the null device means making OS I/O
>> calls -- needless overhead just to find out how long a string -- which
>> is being put together entirely in userland -- needs to be.
> 
> But if you have a simple better way of achieving it ...

snprintf(3) and vsnprintf(3) return the total number of bytes needed for 
the final result. So just call them once with all the right arguments and 
a zero-length buffer, and use the result to allocate a buffer of the right 
length, and call them again.

<https://manpages.debian.org/vsnprintf(3)>

And of course you should be using va_end(3) and va_start(3) again before 
the second call. This allows for traversing the argument list multiple 
times.