summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Michael <devilhorns@comcast.net>2021-02-12 14:43:30 -0500
committerChristopher Michael <devilhorns@comcast.net>2021-02-12 14:43:30 -0500
commitba17e21d9c26315d5d2af880142b3f4f9e786da9 (patch)
treebdb1845529d5372f4b1571260db51bf91667401e
parenta4cbdc8d4ec9c9ae88a36ee3ec81766297501c6b (diff)
express: Use malloc instead of mmap
-rw-r--r--src/bin/grid_save.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/bin/grid_save.c b/src/bin/grid_save.c
index 198d69e..45de6de 100644
--- a/src/bin/grid_save.c
+++ b/src/bin/grid_save.c
@@ -113,16 +113,18 @@ _alloc_new(int size, unsigned char gen)
113 // so allocate a new block 113 // so allocate a new block
114 sz = GS_MMAP_SIZE; 114 sz = GS_MMAP_SIZE;
115 // get mmaped anonymous memory so when freed it goes away from the system 115 // get mmaped anonymous memory so when freed it goes away from the system
116 ptr = mmap(NULL, sz, PROT_READ | PROT_WRITE, 116 ptr = malloc(sz);
117 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); 117
118 if (ptr == MAP_FAILED) 118 /* ptr = mmap(NULL, sz, PROT_READ | PROT_WRITE, */
119 /* MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); */
120 if (!ptr)
119 { 121 {
120 ERR("Cannot allocate more memory with mmap MAP_ANONYMOUS"); 122 ERR("Cannot allocate more memory with mmap MAP_ANONYMOUS");
121 return NULL; 123 return NULL;
122 } 124 }
123 125
124 // note - we SHOULD memset to 0, but we are assuming mmap anon give 0 pages 126 // note - we SHOULD memset to 0, but we are assuming mmap anon give 0 pages
125 //memset(ptr, 0, newsize); 127 memset(ptr, 0, sz);//newsize);
126 128
127 al = (Alloc *)ptr; 129 al = (Alloc *)ptr;
128 al->size = sz; 130 al->size = sz;
@@ -176,7 +178,9 @@ _gs_free(void *ptr)
176 al->allocated -= sz; 178 al->allocated -= sz;
177 if (al->count > 0) return; 179 if (al->count > 0) return;
178 alloc[al->slot] = NULL; 180 alloc[al->slot] = NULL;
179 munmap(al, al->size); 181
182 free(al);
183// munmap(al, al->size);
180} 184}
181 185
182static void 186static void