Path: ...!feeds.phibee-telecom.net!3.eu.feeder.erje.net!feeder.erje.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Janis Papanagnou Newsgroups: comp.lang.c Subject: Re: Whaddaya think? Date: Sun, 16 Jun 2024 12:03:21 +0200 Organization: A noiseless patient Spider Lines: 55 Message-ID: References: <666ded36$0$958$882e4bbb@reader.netnews.com> <20240616015649.000051a0@yahoo.com> <8734pd4g3s.fsf@nosuchdomain.example.com> <20240616111134.00001f18@yahoo.com> <20240616123850.00002d93@yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Injection-Date: Sun, 16 Jun 2024 12:03:22 +0200 (CEST) Injection-Info: dont-email.me; posting-host="567efb17d94aca7729125b64ceeb67a7"; logging-data="14712"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19OnKDLNP1xR7b2yQnHhd69" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 Cancel-Lock: sha1:1yUhMaG2NpaKMQoFGh5uqhZmIJI= X-Enigmail-Draft-Status: N1110 In-Reply-To: <20240616123850.00002d93@yahoo.com> Bytes: 3288 On 16.06.2024 11:38, Michael S wrote: > On Sun, 16 Jun 2024 11:07:22 +0200 > Janis Papanagnou 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 > [...]