diff --git a/util/mmap.h b/util/mmap.h index 20edaf9a7a0..88d649b249d 100644 --- a/util/mmap.h +++ b/util/mmap.h @@ -110,9 +110,12 @@ namespace mongo { void printMemInfo( const char * where ); -//#include "ramstore.h" -// typedef RamStoreFile MMF; +//#define _RAMSTORE +#if defined(_RAMSTORE) +#include "ramstore.h" + typedef RamStoreFile MMF; +#else typedef MemoryMappedFile MMF; - +#endif } // namespace mongo diff --git a/util/ramstore.h b/util/ramstore.h index 183f91f9310..5c34e105a6e 100644 --- a/util/ramstore.h +++ b/util/ramstore.h @@ -20,7 +20,7 @@ class RamStoreFile : public MongoFile { char name[256]; struct Node { - void *p; + char *p; int len; Node() : len(0) { } }; @@ -32,12 +32,13 @@ class RamStoreFile : public MongoFile { Node& n = _m[offset]; if( n.len == 0 ) { // create - cout << "CREATE ofs:" << offset << " len:" << maxLen << endl; + cout << "CREATE " << name << " ofs:" << offset << " len:" << maxLen << endl; assert( maxLen >= 0 ); - n.p = calloc(maxLen+1, 1); + n.p = (char *) calloc(maxLen+1, 1); n.len = maxLen; } assert( n.len >= maxLen ); + assert( n.p[n.len] == 0 ); return n.p; }