casting in fbdev
[winnie] / libwinnie / src / shalloc.cc
index 5d4715a..1bb7db2 100644 (file)
@@ -21,8 +21,8 @@ Author: Eleni Maria Stea <elene.mst@gmail.com>
 
 #include <assert.h>
 #include <stdio.h>
-#include <stdlib.h>
 #include <stdint.h>
+#include <stdlib.h>
 #include <string.h>
 
 #include <errno.h>
@@ -35,9 +35,6 @@ Author: Eleni Maria Stea <elene.mst@gmail.com>
 
 #include "shalloc.h"
 
-#define SHMNAME        "/winnie.shm"
-
-#define POOL_SIZE 16777216
 #define BLOCK_SIZE 512
 
 #define NUM_BLOCKS (POOL_SIZE / BLOCK_SIZE)
@@ -80,8 +77,6 @@ bool init_shared_memory()
                fprintf(stderr, "Failed to map shared memory: %s\n", strerror(errno));
        }
 
-       shm_unlink(SHMNAME);
-
        for(int i=0; i<BITMAP_SIZE; i++) {
                bitmap[i] = 0;
        }
@@ -98,6 +93,7 @@ void destroy_shared_memory()
        if(munmap(pool, POOL_SIZE) == -1) {
                fprintf(stderr, "Failed to unmap shared memory: %s\n", strerror(errno));
        }
+       shm_unlink(SHMNAME);
 }
 
 void *sh_malloc(size_t bytes)