in progress: added shalloc.h/cc did nothing :p
authorEleni Maria Stea <elene.mst@gmail.com>
Wed, 6 Mar 2013 23:00:23 +0000 (01:00 +0200)
committerEleni Maria Stea <elene.mst@gmail.com>
Wed, 6 Mar 2013 23:00:23 +0000 (01:00 +0200)
src/shalloc.cc [new file with mode: 0644]
src/shalloc.h [new file with mode: 0644]

diff --git a/src/shalloc.cc b/src/shalloc.cc
new file mode 100644 (file)
index 0000000..d8f97dc
--- /dev/null
@@ -0,0 +1,29 @@
+#include <map>
+#include <stdlib.h>
+
+#include "shalloc.h"
+
+#define POOL_SIZE 16777216
+#define BLOCK_SIZE 1024
+
+static unsigned char *pool;
+static std::map<unsigned char*, size_t> alloc_sizes;
+//address size
+
+bool init_shared_memory()
+{
+       if(!(pool = (unsigned char *)malloc(POOL_SIZE))) {
+               return false;
+       }
+}
+
+void destroy_shared_memory()
+{
+       //TODO print statistics
+       free(pool);
+}
+
+// an zitaei 45 mb 8a vriskw posa blocks kai meta
+// 8a psaxnw tosa sunexomena bits sto bitmap
+// an den exei return 0
+// pool[arxidi]
diff --git a/src/shalloc.h b/src/shalloc.h
new file mode 100644 (file)
index 0000000..ce9d184
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef SHALLOC_H_
+#define SHALLOC_H_
+
+bool init_shared_memory();
+void destroy_shared_memory();
+
+void *shmalloc(size_t bytes);
+void shmfree(void *ptr);
+
+#endif // SHALLOC_H_