Bug 890144 - Add copedCloseFile to reduce memory leak. r=jlebar

This commit is contained in:
Viral Wang 2013-07-23 08:30:55 -04:00
parent 0c2d31d582
commit 3ef8873243

View File

@ -68,6 +68,19 @@ struct ScopedClosePRFDTraits
};
typedef Scoped<ScopedClosePRFDTraits> AutoFDClose;
/* RAII wrapper for FILE descriptors */
struct ScopedCloseFileTraits
{
typedef FILE *type;
static type empty() { return nullptr; }
static void release(type f) {
if (f) {
fclose(f);
}
}
};
typedef Scoped<ScopedCloseFileTraits> ScopedCloseFile;
/**
* Fallocate efficiently and continuously allocates files via fallocate-type APIs.
* This is useful for avoiding fragmentation.