gliethttpgliethttp.blog.chinaunix.net
gliethttp
全部博文(2005)
2014年(2)
2013年(2)
2012年(16)
2011年(66)
2010年(368)
2009年(743)
2008年(491)
2007年(317)
linux_zj
程睿
mzh2100
dogsun88
叶绍琛
kowems
gongping
chumojin
高泽然
xy7777
os123456
hiderhao
zahassio
byy6by
zxy11861
COVID_19
a1960048
swzswz
分类: C/C++
2007-07-09 17:02:48
浅析μC/GUI-v3.98之WM_H2P()句柄hWin转内存函数文章来源:http://gliethttp.cublog.cn#define WM_H2P(hWin) ((WM_Obj*)GUI_ALLOC_h2p(hWin)) //锁定hWin句柄对应的内存空间-------------------------------------------------------------------------------------1.数据结构gui/core/GUIAlloc.c#define GUI_ALLOC_SIZE 50000 //自定义malloc的空间大小#define GUI_MAXBLOCKS (2 + GUI_ALLOC_SIZE / 32) //目录索引总数(4字节对齐情况下)typedef union { int aintHeap[GUI_ALLOC_SIZE /4]; //4字节对齐 U8 abHeap[GUI_ALLOC_SIZE];} GUI_HEAP;typedef struct { GUI_ALLOC_DATATYPE Off; //内存偏移量 GUI_ALLOC_DATATYPE Size; //2007-07-09 gliethttp HANDLE Next; //各内存目录索引之间的双向链表 HANDLE Prev;} tBlock;GUI_MEM_ALLOC GUI_HEAP GUI_Heap GUI_ALLOC_LOCATION; //malloc申请的heap专用空间static tBlock aBlock[GUI_MAXBLOCKS];-------------------------------------------------------------------------------------2.GUI_ALLOC_h2p()函数gui/core/GUIAlloc.cvoid* GUI_ALLOC_h2p(GUI_HMEM hMem) { GUI_ASSERT_LOCK(); #if GUI_DEBUG_LEVEL > 0 if (!hMem) { GUI_DEBUG_ERROROUT("\n"__FILE__ " GUI_ALLOC_h2p: illegal argument (0 handle)"); return 0; } if (aBlock[hMem].Size == 0) { GUI_DEBUG_ERROROUT("Dereferencing free block"); } #endif return HMEM2PTR(hMem); //返回hWin句柄对应的内存起址}-------------------------------------------------------------------------------------3.HMEM2PTR()宏gui/core/GUIAlloc.c#define HMEM2PTR(hMem) (void*)&GUI_Heap.abHeap[aBlock[hMem].Off]//hWin句柄对应的内存起址GUI_Heap.abHeap+aBlock[hMem].Off
浅析μC/GUI-v3.98之WM_H2P()句柄hWin转内存函数文章来源:http://gliethttp.cublog.cn#define WM_H2P(hWin) ((WM_Obj*)GUI_ALLOC_h2p(hWin)) //锁定hWin句柄对应的内存空间-------------------------------------------------------------------------------------1.数据结构
gui/core/GUIAlloc.c#define GUI_ALLOC_SIZE 50000 //自定义malloc的空间大小#define GUI_MAXBLOCKS (2 + GUI_ALLOC_SIZE / 32) //目录索引总数(4字节对齐情况下)typedef union { int aintHeap[GUI_ALLOC_SIZE /4]; //4字节对齐 U8 abHeap[GUI_ALLOC_SIZE];} GUI_HEAP;typedef struct { GUI_ALLOC_DATATYPE Off; //内存偏移量 GUI_ALLOC_DATATYPE Size; //2007-07-09 gliethttp HANDLE Next; //各内存目录索引之间的双向链表 HANDLE Prev;} tBlock;GUI_MEM_ALLOC GUI_HEAP GUI_Heap GUI_ALLOC_LOCATION; //malloc申请的heap专用空间static tBlock aBlock[GUI_MAXBLOCKS];-------------------------------------------------------------------------------------2.GUI_ALLOC_h2p()函数gui/core/GUIAlloc.cvoid* GUI_ALLOC_h2p(GUI_HMEM hMem) { GUI_ASSERT_LOCK(); #if GUI_DEBUG_LEVEL > 0 if (!hMem) { GUI_DEBUG_ERROROUT("\n"__FILE__ " GUI_ALLOC_h2p: illegal argument (0 handle)"); return 0; } if (aBlock[hMem].Size == 0) { GUI_DEBUG_ERROROUT("Dereferencing free block"); } #endif return HMEM2PTR(hMem); //返回hWin句柄对应的内存起址}-------------------------------------------------------------------------------------3.HMEM2PTR()宏gui/core/GUIAlloc.c#define HMEM2PTR(hMem) (void*)&GUI_Heap.abHeap[aBlock[hMem].Off]//hWin句柄对应的内存起址GUI_Heap.abHeap+aBlock[hMem].Off
上一篇:浅析μC/GUI-v3.98之GUI_ALLOC_AllocZero()内存申请转句柄hWin函数
下一篇:浅析μC/GUI-v3.98之WM_CreateWindowAsChild窗体创建函数
登录 注册