From 12274901ac01898b01b93e15b5b87dec3348afae Mon Sep 17 00:00:00 2001 From: Eleni Maria Stea Date: Thu, 7 Mar 2013 01:00:23 +0200 Subject: [PATCH] in progress: added shalloc.h/cc did nothing :p --- src/shalloc.cc | 29 +++++++++++++++++++++++++++++ src/shalloc.h | 10 ++++++++++ 2 files changed, 39 insertions(+) create mode 100644 src/shalloc.cc create mode 100644 src/shalloc.h diff --git a/src/shalloc.cc b/src/shalloc.cc new file mode 100644 index 0000000..d8f97dc --- /dev/null +++ b/src/shalloc.cc @@ -0,0 +1,29 @@ +#include +#include + +#include "shalloc.h" + +#define POOL_SIZE 16777216 +#define BLOCK_SIZE 1024 + +static unsigned char *pool; +static std::map 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 index 0000000..ce9d184 --- /dev/null +++ b/src/shalloc.h @@ -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_ -- 1.7.10.4