rename snapshotStack -> SnapshotStack
[model-checker.git] / snapshot-interface.cc
index b3da9cf95b8c4dc929c5a7c3173696d18014d001..26e0067e729351b7bc5193d13ba759dd1e309803 100644 (file)
@@ -1,11 +1,3 @@
-/* -*- Mode: C; indent-tabs-mode: t -*- */
-
-#define MYBINARYNAME "model"
-#define MYLIBRARYNAME "libmodel.so"
-#define MYALLOCNAME  "libmymemory.so"
-#define PROCNAME      "/proc/*/maps"
-#define REPLACEPOS             6
-#define PAGESIZE 4096
 #include "snapshot-interface.h"
 #include <iostream>
 #include <fstream>
@@ -13,9 +5,20 @@
 #include <sys/types.h>
 #include <sstream>
 #include <cstring>
+#include <string>
 #include <cassert>
+#include <vector>
+#include <utility>
+
+#define MYBINARYNAME "model"
+#define MYLIBRARYNAME "libmodel.so"
+#define PROCNAME      "/proc/*/maps"
+#define REPLACEPOS             6
+#define PAGESIZE 4096
+
+typedef std::basic_string<char, std::char_traits<char>, MyAlloc<char> > MyString;
 
-snapshotStack * snapshotObject;
+SnapshotStack * snapshotObject;
 
 /*This looks like it might leak memory...  Subramanian should fix this. */
 
@@ -49,10 +52,9 @@ static void takeSegmentSnapshot( const MyString & lineText ){
 void SnapshotGlobalSegments(){
        MyString fn = PROCNAME;
        static char sProcessSize[ 12 ] = { 0 };
-       std::pair< const char *, bool > dataSect[ 3 ];
+       std::pair< const char *, bool > dataSect[ 2 ];
        dataSect[ 0 ] = std::make_pair( MYBINARYNAME, false );
        dataSect[ 1 ] = std::make_pair( MYLIBRARYNAME, false );
-       dataSect[ 2 ] = std::make_pair( MYALLOCNAME, false );
        static pid_t sProcID = 0;
        if( 0 == sProcID ) {
                sProcID = getpid();     
@@ -77,17 +79,17 @@ void SnapshotGlobalSegments(){
        }
 }
 
-//class definition of snapshotStack.....
+//class definition of SnapshotStack.....
 //declaration of constructor....
-snapshotStack::snapshotStack(){
+SnapshotStack::SnapshotStack(){
        SnapshotGlobalSegments();
        stack=NULL;
 }
        
-snapshotStack::~snapshotStack(){
+SnapshotStack::~SnapshotStack(){
 }
        
-int snapshotStack::backTrackBeforeStep(int seqindex) {
+int SnapshotStack::backTrackBeforeStep(int seqindex) {
        while(true) {
                if (stack->index<=seqindex) {
                        //have right entry
@@ -95,13 +97,13 @@ int snapshotStack::backTrackBeforeStep(int seqindex) {
                        return stack->index;
                }
                struct stackEntry *tmp=stack;
-               free(tmp);
+               MYFREE(tmp);
                stack=stack->next;
        }
 }
 
-void snapshotStack::snapshotStep(int seqindex) {
-       struct stackEntry *tmp=(struct stackEntry *)malloc(sizeof(struct stackEntry));
+void SnapshotStack::snapshotStep(int seqindex) {
+       struct stackEntry *tmp=(struct stackEntry *)MYMALLOC(sizeof(struct stackEntry));
        tmp->next=stack;
        tmp->index=seqindex;
        tmp->snapshotid=takeSnapshot();