From: Johannes Schindelin Date: Sun, 14 Feb 2010 18:10:01 GMT Subject: Re: [PATCH] don't use mmap() to hash files Message-ID: In-Reply-To: <20100214024259.GB9704@dpotapov.dyndns.org> Hi, On Sun, 14 Feb 2010, Dmitry Potapov wrote: > On Sun, Feb 14, 2010 at 02:53:58AM +0100, Johannes Schindelin wrote: > > On Sun, 14 Feb 2010, Dmitry Potapov wrote: > > > > > + if (strbuf_read(&sbuf, fd, 4096) >= 0) > > > > How certain are you at this point that all of fd's contents fit into > > your memory? > > You can't be sure... In fact, we know mmap() also may fail for huge > files, so can strbuf_read(). That's comparing oranges to apples. In one case, the address space runs out, in the other the available memory. The latter is much more likely. > > And even if you could be certain, a hint is missing that > > strbuf_read(), its name notwithstanding, does not read NUL-terminated > > strings. Oh, and the size is just a hint for the initial size, and it > > reads until EOF. That has to be said in the commit message. > > I did not add _any_ new code, including the above line. It was there > before my patch. But that explanation does not answer my question, does it? And my question was not unreasonable to ask, was it? Ciao, Dscho