Sujet : Re: Whaddaya think?
De : janis_papanagnou+ng (at) *nospam* hotmail.com (Janis Papanagnou)
Groupes : comp.lang.cDate : 16. Jun 2024, 11:03:21
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v4md99$ebo$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0
On 16.06.2024 11:38, Michael S wrote:
On Sun, 16 Jun 2024 11:07:22 +0200
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
On 16.06.2024 10:11, Michael S wrote:
>
Not sure what this code is supposed to do.
>
Not sure what you're comment is supposed to tell me.
>
I hoped that after you would read the manual you will know.
The point is that I inspected these manuals before I wrote the
test code, and after some initial mistakes it ran as expected.
But it obviously didn't work out.
So, I'd tell a little more:
1. It does not read one line of arbitrary length
No, it does not do that. I wrote the test program as one way
to circumvent the problem reading data of arbitrary length.
The relevant text of my previous post was:
| Would it be sensible to have a malloc()'ed buffer used for the first
| fgets() and then subsequent fgets() work on the realloc()'ed part? I
| suppose the previously set data in the malloc area would be retained
| so that there's no re-composition of cut numbers necessary?
It's intention was to read chunks of data to construct the
buffer subsequently, starting from a small buffer instance and
let it grow as more data (from the single external data line)
are read. The intention was to avoid having to wastefully
specify a too large buffer from the beginning, yet not being
sure it suffices.
(And just to make sure; "arbitrary" length is of course meant
to be in the range of available memory, neither exa-byte, nor
"unlimited" was meant.)
2. There is more than one mistake
I'm sure that's possible with an "ad hoc test code". Only your
comment is meaningless without pointing me to any issue you see.
3. All mistakes seems to be caused by deep misconceptions about fgets()
and realloc().
Again; which ones?
Janis
[...]