Sujet : Re: FreeTDS port to VMS V9.x on x86?
De : ldo (at) *nospam* nz.invalid (Lawrence D'Oliveiro)
Groupes : comp.os.vmsDate : 27. Jun 2025, 01:03:04
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <103kn3o$3nvfg$4@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
User-Agent : Pan/0.162 (Pokrosvk)
On Tue, 24 Jun 2025 12:25:50 -0400, Arne Vajhøj wrote:
The algorithm is basically to try vsnprintf with buffers increasing in
size 512, 1024, 1536, ... until there is space.
That is very inefficient compared to just use the return value.
It’s a good choice in the absence of any other clues as to how much to
allocate. I have used it myself. (Of course having an explicit number
returned is best of all.)
One may conduct statistical analyses, I suppose to decide on the optimum
multiplication factor. E.g. would going up in powers of 3 better than
powers of 2? I suspect larger factors (too far from e = 2.71828 ...) would
not be worth using.
And don’t forget to do a realloc(3) at the end, to trim the unused part of
the last allocation.