std.md5: Lower buffer size in mdFile example

When trying to use the function from the example as-is on a large
directory tree, the D program will quickly run out of memory due
to false pointers on 32-bit machines (File.byChunk will allocate
a new buffer for every file).
This commit is contained in:
Vladimir Panteleev 2012-03-31 20:02:07 +03:00
parent b93e9c9fd4
commit ffd3752a2e

View file

@ -49,7 +49,7 @@ void mdFile(string filename)
MD5_CTX context; MD5_CTX context;
context.start(); context.start();
foreach (buffer; File(filename).byChunk(4096 * 1024)) foreach (buffer; File(filename).byChunk(64 * 1024))
context.update(buffer); context.update(buffer);
context.finish(digest); context.finish(digest);
writefln("MD5 (%s) = %s", filename, digestToString(digest)); writefln("MD5 (%s) = %s", filename, digestToString(digest));