diff options
author | Benety Goh <benety@mongodb.com> | 2014-08-13 16:02:17 -0400 |
---|---|---|
committer | Benety Goh <benety@mongodb.com> | 2014-08-15 01:44:41 -0400 |
commit | be05259d36ec5f44c821c8f2d103a4ee83ebaf53 (patch) | |
tree | 08564e54e580e6dde94b7a5e89e8c4021fa457ef /src/mongo/bson/util/builder.h | |
parent | 7a1a0ce4ca6bbdf047adc7528310078ef7ca08f8 (diff) | |
download | mongo-be05259d36ec5f44c821c8f2d103a4ee83ebaf53.tar.gz |
SERVER-14889 wrapped all malloc/realloc calls within src/mongo with mongoMalloc/mongoRealloc.
if memory allocation fails, report error and exit.
Diffstat (limited to 'src/mongo/bson/util/builder.h')
-rw-r--r-- | src/mongo/bson/util/builder.h | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/mongo/bson/util/builder.h b/src/mongo/bson/util/builder.h index 00924458e7a..38e24b59d5f 100644 --- a/src/mongo/bson/util/builder.h +++ b/src/mongo/bson/util/builder.h @@ -38,6 +38,7 @@ #include "mongo/bson/inline_decls.h" #include "mongo/base/string_data.h" +#include "mongo/util/allocator.h" #include "mongo/util/assert_util.h" namespace mongo { @@ -74,8 +75,8 @@ namespace mongo { class TrivialAllocator { public: - void* Malloc(size_t sz) { return malloc(sz); } - void* Realloc(void *p, size_t sz) { return realloc(p, sz); } + void* Malloc(size_t sz) { return mongoMalloc(sz); } + void* Realloc(void *p, size_t sz) { return mongoRealloc(p, sz); } void Free(void *p) { free(p); } }; @@ -84,18 +85,18 @@ namespace mongo { enum { SZ = 512 }; void* Malloc(size_t sz) { if( sz <= SZ ) return buf; - return malloc(sz); + return mongoMalloc(sz); } void* Realloc(void *p, size_t sz) { if( p == buf ) { if( sz <= SZ ) return buf; - void *d = malloc(sz); + void *d = mongoMalloc(sz); if ( d == 0 ) msgasserted( 15912 , "out of memory StackAllocator::Realloc" ); memcpy(d, p, SZ); return d; } - return realloc(p, sz); + return mongoRealloc(p, sz); } void Free(void *p) { if( p != buf ) |