[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: read-file
From: |
Simon Josefsson |
Subject: |
Re: read-file |
Date: |
Wed, 21 Jun 2006 10:03:05 +0200 |
User-agent: |
Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.50 (gnu/linux) |
Paul Eggert <address@hidden> writes:
> Simon Josefsson <address@hidden> writes:
>
>> --- read-file.c 16 Jun 2006 21:26:36 +0200 1.1
>> +++ read-file.c 17 Jun 2006 18:22:29 +0200
>> @@ -43,6 +43,9 @@
>> if (!buf)
>> return NULL;
>>
>> + if (ferror (stream))
>> + return NULL;
>> +
>> while (!feof (stream))
>> {
>> size_t count;
>
> But that would leak memory and would cause errno to contain junk on
> failure, even on a POSIX host.
>
> How about the following patch instead? It fixes a few other minor
> glitches I spotted. I think it addresses Larry Jones's objections as
> well, since it causes the code to always invoke 'read'; on hosts
> conforming to the C Standard this is fine, and on other hosts where
> feof/ferror isn't sticky, the usual convention is to retry the read
> anyway, so it's better in that case. I haven't tested it, though.
I've tested it briefly, and it seems to work, so I installed it.
Thanks!
/Simon
- Re: read-file, (continued)
Re: read-file, Simon Josefsson, 2006/06/16
- Re: read-file, Larry Jones, 2006/06/16
- Re: read-file, Simon Josefsson, 2006/06/16
- Re: read-file, Larry Jones, 2006/06/16
- Re: read-file, Simon Josefsson, 2006/06/17
- Re: read-file, Paul Eggert, 2006/06/19
- Re: read-file,
Simon Josefsson <=