diff options
Diffstat (limited to 'ldmicro/lib')
-rw-r--r-- | ldmicro/lib/linuxUI/linuxLD.cpp | 102 |
1 files changed, 51 insertions, 51 deletions
diff --git a/ldmicro/lib/linuxUI/linuxLD.cpp b/ldmicro/lib/linuxUI/linuxLD.cpp index cdeb190..4b86441 100644 --- a/ldmicro/lib/linuxUI/linuxLD.cpp +++ b/ldmicro/lib/linuxUI/linuxLD.cpp @@ -7,7 +7,7 @@ HANDLE HeapCreate(DWORD flOptions, SIZE_T dwInitialSize, SIZE_T dwMaximumSize) HANDLE hHeap = NULL; HEAPRECORD hHeapRecord; hHeapRecord.dwMaximumSize = dwMaximumSize; - hHeap = malloc(dwInitialSize); + // hHeap = malloc(dwInitialSize); if (hHeap == NULL) return NULL; @@ -23,79 +23,79 @@ HANDLE HeapCreate(DWORD flOptions, SIZE_T dwInitialSize, SIZE_T dwMaximumSize) LPVOID HeapAlloc(HANDLE hHeap, DWORD dwFlags, SIZE_T dwBytes) { - if (hHeap == NULL) - { + // if (hHeap == NULL) + // { // printf("Alloc**********NULL HEAP***************\n"); LPVOID p = malloc(dwBytes); return p; - } + // } - auto it = std::find_if(HeapRecords.begin(), HeapRecords.end(), [&hHeap](HEAPRECORD &Record) { return Record.hHeap == hHeap; }); + // auto it = std::find_if(HeapRecords.begin(), HeapRecords.end(), [&hHeap](HEAPRECORD &Record) { return Record.hHeap == hHeap; }); - if (it == HeapRecords.end()) - return NULL; - - if ((*it).dwAllocatedSizeOffset + dwBytes > (*it).dwSize) - { - if ((*it).dwMaximumSize != 0) - if((*it).dwAllocatedSizeOffset + dwBytes > (*it).dwMaximumSize) - return NULL; + // if (it == HeapRecords.end()) + // return NULL; + + // if ((*it).dwAllocatedSizeOffset + dwBytes > (*it).dwSize) + // { + // if ((*it).dwMaximumSize != 0) + // if((*it).dwAllocatedSizeOffset + dwBytes > (*it).dwMaximumSize) + // return NULL; - (*it).hHeap = realloc((*it).hHeap, (*it).dwAllocatedSizeOffset + dwBytes); - hHeap = (*it).hHeap; - } + // (*it).hHeap = realloc((*it).hHeap, (*it).dwAllocatedSizeOffset + dwBytes); + // hHeap = (*it).hHeap; + // } - /// HEAP_ZERO_MEMORY is set by default - DWORD flags = MAP_ANONYMOUS; + // /// HEAP_ZERO_MEMORY is set by default + // DWORD flags = MAP_ANONYMOUS; - // if ( !((dwFlags & HEAP_ZERO_MEMORY) == HEAP_ZERO_MEMORY) ) - // flags = MAP_ANONYMOUS | MAP_UNINITIALIZED; + // // if ( !((dwFlags & HEAP_ZERO_MEMORY) == HEAP_ZERO_MEMORY) ) + // // flags = MAP_ANONYMOUS | MAP_UNINITIALIZED; - /* Use for setting a meamory chunck with some value - * void * memset ( void * ptr, int value, size_t num ); - */ - LPVOID p = mmap(hHeap + (*it).dwAllocatedSizeOffset, dwBytes, PROT_EXEC, flags, -1, 0); + // /* Use for setting a meamory chunck with some value + // * void * memset ( void * ptr, int value, size_t num ); + // */ + // LPVOID p = mmap(hHeap + (*it).dwAllocatedSizeOffset, dwBytes, PROT_EXEC, flags, -1, 0); - if (p == NULL) - return NULL; + // if (p == NULL) + // return NULL; - (*it).dwAllocatedSizeOffset += dwBytes; - HEAPCHUNCK chunck; - chunck.Chunck = p; - chunck.dwSize = dwBytes; - (*it).Element.push_back(chunck); - - return p; + // (*it).dwAllocatedSizeOffset += dwBytes; + // HEAPCHUNCK chunck; + // chunck.Chunck = p; + // chunck.dwSize = dwBytes; + // (*it).Element.push_back(chunck); + + // return p; } BOOL HeapFree(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem) { /// if NULL free() - if (hHeap == NULL) - { + // if (hHeap == NULL) + // { // printf("free*********NULL HEAP***************\n"); free(lpMem); return TRUE; - } - auto heap_it = std::find_if(HeapRecords.begin(), HeapRecords.end(), [&hHeap](HEAPRECORD &Record) { return Record.hHeap == hHeap; }); + // } + // auto heap_it = std::find_if(HeapRecords.begin(), HeapRecords.end(), [&hHeap](HEAPRECORD &Record) { return Record.hHeap == hHeap; }); - if (heap_it == HeapRecords.end()) - return FALSE; + // if (heap_it == HeapRecords.end()) + // return FALSE; - auto chunck_it = std::find_if((*heap_it).Element.begin(), (*heap_it).Element.end(), [&lpMem](HEAPCHUNCK &Chunck) { return Chunck.Chunck == lpMem; }); + // auto chunck_it = std::find_if((*heap_it).Element.begin(), (*heap_it).Element.end(), [&lpMem](HEAPCHUNCK &Chunck) { return Chunck.Chunck == lpMem; }); - if (chunck_it == (*heap_it).Element.end()) - return FALSE; + // if (chunck_it == (*heap_it).Element.end()) + // return FALSE; - int result = munmap((*chunck_it).Chunck, (*chunck_it).dwSize); - - if (result == 0) - { - (*heap_it).Element.erase(chunck_it); - return TRUE; - } - else - return FALSE; + // int result = munmap((*chunck_it).Chunck, (*chunck_it).dwSize); + + // if (result == 0) + // { + // (*heap_it).Element.erase(chunck_it); + // return TRUE; + // } + // else + // return FALSE; } |