bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] read-file: Avoid memory reallocations with seekable files.


From: Paul Eggert
Subject: Re: [PATCH] read-file: Avoid memory reallocations with seekable files.
Date: Tue, 03 Aug 2010 18:18:20 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.11) Gecko/20100713 Thunderbird/3.0.6

On 08/03/10 17:00, Giuseppe Scrivano wrote:

> +      if (alloc_off -  (off_t) (size_t) alloc_off
> +          || (size_t) alloc_off + 1 < (size_t) alloc_off)
> +        break;

It would be clearer without the casts.  (Casts are often
overkill in C; they disable too much checking.)  Also, I'm still
dubious about going ahead with a file that's too
large to fit into memory.  Better and clearer would be
something like this:

  if (SIZE_MAX <= alloc_off)
    {
      errno = ENOMEM;
      return NULL;
    }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]