diff options
Diffstat (limited to 'intern')
-rw-r--r-- | intern/guardedalloc/intern/mallocn.c | 32 | ||||
-rw-r--r-- | intern/guardedalloc/intern/mmap_win.c | 38 |
2 files changed, 35 insertions, 35 deletions
diff --git a/intern/guardedalloc/intern/mallocn.c b/intern/guardedalloc/intern/mallocn.c index f1c9f9e6363..caf551c84d8 100644 --- a/intern/guardedalloc/intern/mallocn.c +++ b/intern/guardedalloc/intern/mallocn.c @@ -373,7 +373,7 @@ void *MEM_mapallocN(size_t len, const char *str) fd = open("/dev/zero", O_RDWR); memh= mmap(0, len+sizeof(MemHead)+sizeof(MemTail), - PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); + PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); close(fd); } #else @@ -698,26 +698,26 @@ static void remlink(volatile localListBase *listbase, void *vlink) static void rem_memblock(MemHead *memh) { - remlink(membase,&memh->next); - if (memh->prev) { - if (memh->next) + remlink(membase,&memh->next); + if (memh->prev) { + if (memh->next) MEMNEXT(memh->prev)->nextname = MEMNEXT(memh->next)->name; - else + else MEMNEXT(memh->prev)->nextname = NULL; - } - - totblock--; - mem_in_use -= memh->len; - - if(memh->mmap) { - mmap_in_use -= memh->len; - if (munmap(memh, memh->len + sizeof(MemHead) + sizeof(MemTail))) - printf("Couldn't unmap memory %s\n", memh->name); - } + } + + totblock--; + mem_in_use -= memh->len; + + if(memh->mmap) { + mmap_in_use -= memh->len; + if (munmap(memh, memh->len + sizeof(MemHead) + sizeof(MemTail))) + printf("Couldn't unmap memory %s\n", memh->name); + } else { if(malloc_debug_memset && memh->len) memset(memh+1, 255, memh->len); - free(memh); + free(memh); } } diff --git a/intern/guardedalloc/intern/mmap_win.c b/intern/guardedalloc/intern/mmap_win.c index 3b366ae7674..24b48d713ef 100644 --- a/intern/guardedalloc/intern/mmap_win.c +++ b/intern/guardedalloc/intern/mmap_win.c @@ -114,7 +114,7 @@ void *mmap(void *UNUSED(start), size_t len, int prot, int flags, int fd, off_t o /* if ( fd == -1 ) { _set_errno( EBADF ); - return MAP_FAILED; + return MAP_FAILED; } */ @@ -128,16 +128,16 @@ void *mmap(void *UNUSED(start), size_t len, int prot, int flags, int fd, off_t o } } else { if ( !DuplicateHandle( GetCurrentProcess(), fhandle, GetCurrentProcess(), - &fhandle, 0, FALSE, DUPLICATE_SAME_ACCESS ) ) { + &fhandle, 0, FALSE, DUPLICATE_SAME_ACCESS ) ) { return MAP_FAILED; } } maphandle = CreateFileMapping(fhandle, NULL, prot_flags, 0, len, NULL); if ( maphandle == 0 ) { - errno = EBADF; + errno = EBADF; return MAP_FAILED; - } + } ptr = MapViewOfFile(maphandle, access_flags, 0, offset, 0); if ( ptr == NULL ) { @@ -159,7 +159,7 @@ void *mmap(void *UNUSED(start), size_t len, int prot, int flags, int fd, off_t o mm->mmap = ptr; mmap_addtail(mmapbase, mm); - return ptr; + return ptr; } /* munmap for windows */ @@ -168,14 +168,14 @@ intptr_t munmap(void *ptr, intptr_t UNUSED(size)) MemMap *mm = mmap_findlink(mmapbase, ptr); if (!mm) { errno=EINVAL; - return -1; + return -1; } UnmapViewOfFile( mm->mmap ); CloseHandle( mm->maphandle ); CloseHandle( mm->fhandle); mmap_remlink(mmapbase, mm); free(mm); - return 0; + return 0; } /* --------------------------------------------------------------------- */ @@ -233,16 +233,16 @@ static int mmap_get_prot_flags (int flags) int prot = PAGE_NOACCESS; if ( ( flags & PROT_READ ) == PROT_READ ) { - if ( ( flags & PROT_WRITE ) == PROT_WRITE ) { - prot = (flags & PROT_EXEC) ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE; + if ( ( flags & PROT_WRITE ) == PROT_WRITE ) { + prot = (flags & PROT_EXEC) ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE; } else { prot = (flags & PROT_EXEC) ? PAGE_EXECUTE_READ : PAGE_READONLY; } - } else if ( ( flags & PROT_WRITE ) == PROT_WRITE ) { + } else if ( ( flags & PROT_WRITE ) == PROT_WRITE ) { prot = (flags & PROT_EXEC) ? PAGE_EXECUTE_READ : PAGE_WRITECOPY; - } else if ( ( flags & PROT_EXEC ) == PROT_EXEC ) { - prot = PAGE_EXECUTE_READ; - } + } else if ( ( flags & PROT_EXEC ) == PROT_EXEC ) { + prot = PAGE_EXECUTE_READ; + } return prot; } @@ -251,16 +251,16 @@ static int mmap_get_access_flags (int flags) int access = 0; if ( ( flags & PROT_READ ) == PROT_READ ) { - if ( ( flags & PROT_WRITE ) == PROT_WRITE ) { - access = FILE_MAP_WRITE; + if ( ( flags & PROT_WRITE ) == PROT_WRITE ) { + access = FILE_MAP_WRITE; } else { access = (flags & PROT_EXEC) ? FILE_MAP_EXECUTE : FILE_MAP_READ; } - } else if ( ( flags & PROT_WRITE ) == PROT_WRITE ) { + } else if ( ( flags & PROT_WRITE ) == PROT_WRITE ) { access = FILE_MAP_COPY; - } else if ( ( flags & PROT_EXEC ) == PROT_EXEC ) { - access = FILE_MAP_EXECUTE; - } + } else if ( ( flags & PROT_EXEC ) == PROT_EXEC ) { + access = FILE_MAP_EXECUTE; + } return access; } |