summaryrefslogtreecommitdiff
path: root/ldmicro/lib/linuxUI/linuxLD.cpp
diff options
context:
space:
mode:
authorNatsuDrag92018-06-20 10:17:48 +0530
committerNatsuDrag92018-06-20 10:17:48 +0530
commit9860c3efa13a305be9fefde4e914dfc7ff6ae834 (patch)
treebd8a81deb0892e60bf36d98270d5eca077ee6c7b /ldmicro/lib/linuxUI/linuxLD.cpp
parente25480293be793d0ab8c78038ff9ef6aa27a8c50 (diff)
parente0dee2ff8d0a6d74f6a07ff73d739d3ac6fd6b22 (diff)
downloadLDMicroGtk-9860c3efa13a305be9fefde4e914dfc7ff6ae834.tar.gz
LDMicroGtk-9860c3efa13a305be9fefde4e914dfc7ff6ae834.tar.bz2
LDMicroGtk-9860c3efa13a305be9fefde4e914dfc7ff6ae834.zip
Pulled and merged.
Diffstat (limited to 'ldmicro/lib/linuxUI/linuxLD.cpp')
-rw-r--r--ldmicro/lib/linuxUI/linuxLD.cpp110
1 files changed, 58 insertions, 52 deletions
diff --git a/ldmicro/lib/linuxUI/linuxLD.cpp b/ldmicro/lib/linuxUI/linuxLD.cpp
index 8778154..a83d15e 100644
--- a/ldmicro/lib/linuxUI/linuxLD.cpp
+++ b/ldmicro/lib/linuxUI/linuxLD.cpp
@@ -10,7 +10,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;
@@ -26,81 +26,79 @@ HANDLE HeapCreate(DWORD flOptions, SIZE_T dwInitialSize, SIZE_T dwMaximumSize)
LPVOID HeapAlloc(HANDLE hHeap, DWORD dwFlags, SIZE_T dwBytes)
{
- cout << "Inside HeapAlloc" << "\n";
- 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);
- (*it).dwAllocatedSizeOffset += dwBytes;
- HEAPCHUNCK chunck;
- chunck.Chunck = p;
- chunck.dwSize = dwBytes;
- (*it).Element.push_back(chunck);
- cout << "Exiting HeapAlloc" << "\n";
-
- return p;
+ // 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);
+ // int result = munmap((*chunck_it).Chunck, (*chunck_it).dwSize);
- if (result == 0)
- {
- (*heap_it).Element.erase(chunck_it);
- return TRUE;
- }
- else
- return FALSE;
+ // if (result == 0)
+ // {
+ // (*heap_it).Element.erase(chunck_it);
+ // return TRUE;
+ // }
+ // else
+ // return FALSE;
}
@@ -119,6 +117,14 @@ HICON LoadImage(HINSTANCE hinst, LPCTSTR lpszName, UINT uType, int cxDesired,
return pixbuf;
}
+void RECT_to_GDRECT(const RECT *rc, GDRECT *gdrc)
+{
+ gdrc->x = rc->left;
+ gdrc->y = rc->top;
+ gdrc->width = rc->right - rc->left;
+ gdrc->height = rc->bottom - rc->top;
+}
+
void OutputDebugString(char* str)
{