add more comments

This commit is contained in:
leitner
2014-06-30 11:40:52 +00:00
parent 25d9c5a6c7
commit 798c06a785
12 changed files with 90 additions and 2 deletions

View File

@@ -11,7 +11,11 @@
#endif
static iarray_page* new_page(size_t pagesize) {
#ifdef __MINGW32__
void* x=malloc(pagesize);
#else
void* x=mmap(0,pagesize,PROT_READ|PROT_WRITE,MAP_ANONYMOUS|MAP_PRIVATE,-1,0);
#endif
if (x==MAP_FAILED) return 0;
return (iarray_page*)x;
}
@@ -41,7 +45,12 @@ void* iarray_allocate(iarray* ia,size_t pos) {
break;
p=&(*p)->next;
}
if (newpage) munmap(newpage,ia->bytesperpage);
if (newpage)
#ifdef __MINGW32__
free(newpage);
#else
munmap(newpage,ia->bytesperpage);
#endif
{
size_t l;
do {

View File

@@ -1,12 +1,18 @@
#include <stdlib.h>
#ifndef __MINGW32__
#include <sys/mman.h>
#endif
#include <unistd.h>
#include "iarray.h"
static void freechain(iarray_page* p,size_t pagesize) {
while (p) {
iarray_page* n=p->next;
#ifdef __MINGW32__
free(p);
#else
munmap(p,pagesize);
#endif
p=n;
}
}