summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDwight <dmerriman@gmail.com>2010-04-06 18:05:30 -0400
committerDwight <dmerriman@gmail.com>2010-04-06 18:05:30 -0400
commit977e24670256cb76e9a9df15cc15fbb58d8f9703 (patch)
tree38e0400edbca94c8540ec5b8f26ae21b694dcad1
parent3cfeda9c9101b9a145f334aa076d83579d51c334 (diff)
downloadmongo-977e24670256cb76e9a9df15cc15fbb58d8f9703.tar.gz
minor mmf
-rw-r--r--util/mmap.h9
-rw-r--r--util/ramstore.h7
2 files changed, 10 insertions, 6 deletions
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;
}