mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-30 01:59:29 +00:00
Bug 890144 - Add copedCloseFile to reduce memory leak. r=jlebar
This commit is contained in:
parent
0c2d31d582
commit
3ef8873243
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user