@@ -42,7 +42,7 @@ extern "C"
4242HHOOK g_hookMain = NULL ;
4343
4444// sweet globals
45- RemapEntryListItem * g_KeyTranslationTable[WIN_KEY_COUNT];
45+ RemapEntryContainerListItem * g_KeyTranslationTable[WIN_KEY_COUNT];
4646RemapEntry* g_KeyTranslationHead = NULL ;
4747void * g_KeyTranslationEnd = NULL ; // pointer indicating the end of the input file data
4848
@@ -69,7 +69,7 @@ __declspec(dllexport) int LoadAndCaptureFromFile(HINSTANCE hInstance, char* sFil
6969 }
7070
7171 // validate file (and compile the "hash" table g_KeyTranslationTable)
72- memset (g_KeyTranslationTable, 0 , WIN_KEY_COUNT * sizeof (RemapEntryListItem *));
72+ memset (g_KeyTranslationTable, 0 , WIN_KEY_COUNT * sizeof (RemapEntryContainerListItem *));
7373
7474 RemapEntry* pEntry = g_KeyTranslationHead;
7575 bool bValidTranslationSet = false ;
@@ -91,21 +91,25 @@ __declspec(dllexport) int LoadAndCaptureFromFile(HINSTANCE hInstance, char* sFil
9191 // if the entry doesn't exist yet for the given input vkey create a new one with a null next pointer
9292 if (NULL == g_KeyTranslationTable[pEntry->inputConfig .virtualKey ])
9393 {
94- g_KeyTranslationTable[pEntry->inputConfig .virtualKey ] = (RemapEntryListItem*)malloc (sizeof (RemapEntryListItem));
95- g_KeyTranslationTable[pEntry->inputConfig .virtualKey ]->pEntry = pEntry;
94+ g_KeyTranslationTable[pEntry->inputConfig .virtualKey ] = (RemapEntryContainerListItem*)malloc (sizeof (RemapEntryContainerListItem));
95+ g_KeyTranslationTable[pEntry->inputConfig .virtualKey ]->pEntryContainer = (RemapEntryContainer*)malloc (sizeof (RemapEntryContainer));
96+ g_KeyTranslationTable[pEntry->inputConfig .virtualKey ]->pEntryContainer ->pEntryState = (RemapEntryState*)malloc (sizeof (RemapEntryState));
97+ g_KeyTranslationTable[pEntry->inputConfig .virtualKey ]->pEntryContainer ->pEntry = pEntry;
9698 g_KeyTranslationTable[pEntry->inputConfig .virtualKey ]->pNext = NULL ;
9799 }
98100 // if the entry does exist create a new entry and append it to the existing linked list
99101 else
100102 {
101- RemapEntryListItem * pKeyItem = g_KeyTranslationTable[pEntry->inputConfig .virtualKey ];
103+ RemapEntryContainerListItem * pKeyItem = g_KeyTranslationTable[pEntry->inputConfig .virtualKey ];
102104 while (NULL != pKeyItem->pNext )
103105 {
104106 pKeyItem = pKeyItem->pNext ;
105107 }
106- pKeyItem->pNext = (RemapEntryListItem *)malloc (sizeof (RemapEntryListItem ));
108+ pKeyItem->pNext = (RemapEntryContainerListItem *)malloc (sizeof (RemapEntryContainerListItem ));
107109 pKeyItem = pKeyItem->pNext ;
108- pKeyItem->pEntry = pEntry;
110+ pKeyItem->pEntryContainer = (RemapEntryContainer*)malloc (sizeof (RemapEntryContainer));
111+ pKeyItem->pEntryContainer ->pEntryState = (RemapEntryState*)malloc (sizeof (RemapEntryState));
112+ pKeyItem->pEntryContainer ->pEntry = pEntry;
109113 pKeyItem->pNext = NULL ;
110114 }
111115 // jump to the next entry
@@ -170,13 +174,16 @@ __declspec(dllexport) void ShutdownCapture()
170174 {
171175 if (NULL != g_KeyTranslationTable[nIdx])
172176 {
173- RemapEntryListItem* pKeyItem = g_KeyTranslationTable[nIdx];
174- RemapEntryListItem* pKeyNextItem = NULL ;
175- while (NULL != pKeyItem )
177+ RemapEntryContainerListItem* pListItem = g_KeyTranslationTable[nIdx];
178+ RemapEntryContainerListItem* pNextItem = NULL ;
179+ while (NULL != pListItem )
176180 {
177- pKeyNextItem = pKeyItem->pNext ;
178- free (pKeyItem);
179- pKeyItem = pKeyNextItem;
181+ pNextItem = pListItem->pNext ;
182+ free (pListItem->pEntryContainer ->pEntryState );
183+ free (pListItem->pEntryContainer );
184+ // NOTE: the entry itself was freed above
185+ free (pListItem);
186+ pListItem = pNextItem;
180187 }
181188 g_KeyTranslationTable[nIdx] = NULL ;
182189 }
0 commit comments