diff options
Diffstat (limited to 'plugins/Variables')
-rw-r--r-- | plugins/Variables/src/parse_variables.cpp | 42 | ||||
-rw-r--r-- | plugins/Variables/src/variables.cpp | 8 | ||||
-rw-r--r-- | plugins/Variables/src/variables.h | 21 |
3 files changed, 23 insertions, 48 deletions
diff --git a/plugins/Variables/src/parse_variables.cpp b/plugins/Variables/src/parse_variables.cpp index d8e7b5814f..30136d8068 100644 --- a/plugins/Variables/src/parse_variables.cpp +++ b/plugins/Variables/src/parse_variables.cpp @@ -20,7 +20,7 @@ #include "variables.h"
// this is for get and put(s)
-static CRITICAL_SECTION csVarRegister;
+static mir_cs csVarRegister;
static VARIABLEREGISTER *vr = NULL;
static int vrCount = 0;
@@ -61,35 +61,6 @@ static TCHAR *searchVariableRegister(TCHAR *szName) return NULL;
}
-int clearVariableRegister(bool bAll)
-{
- int count = 0;
- mir_cslock lck(csVarRegister);
- for (int i = 0; i < vrCount; i++) {
- if (!bAll && vr[i].dwOwnerThread != GetCurrentThreadId())
- continue;
-
- mir_free(vr[i].szName);
- mir_free(vr[i].szText);
- if (vrCount > 1) {
- memcpy(&vr[i], &vr[vrCount-1], sizeof(VARIABLEREGISTER));
- vr = (VARIABLEREGISTER*)mir_realloc(vr, (vrCount-1)*sizeof(VARIABLEREGISTER));
- if (vr == NULL)
- return -1;
-
- vrCount--;
- }
- else {
- mir_free(vr);
- vr = NULL;
- vrCount = 0;
- }
- count += 1;
- }
-
- return count;
-}
-
static TCHAR *parsePut(ARGUMENTSINFO *ai)
{
FORMATINFO fi;
@@ -131,11 +102,16 @@ void registerVariablesTokens() registerIntToken(GET, parseGet, TRF_FUNCTION, LPGEN("Variables")"\t(x)\t"LPGEN("variable set by put(s) with name x"));
registerIntToken(PUT, parsePut, TRF_FUNCTION, LPGEN("Variables")"\t(x,y)\t"LPGEN("x, and stores y as variable named x"));//TRF_UNPARSEDARGS);
registerIntToken(PUTS, parsePuts, TRF_FUNCTION, LPGEN("Variables")"\t(x,y)\t"LPGEN("only stores y as variables x"));//TRF_UNPARSEDARGS);
- InitializeCriticalSection(&csVarRegister);
}
void unregisterVariablesTokens()
{
- clearVariableRegister(true);
- DeleteCriticalSection(&csVarRegister);
+ mir_cslock lck(csVarRegister);
+ for (int i = 0; i < vrCount; i++) {
+ mir_free(vr[i].szName);
+ mir_free(vr[i].szText);
+ }
+ mir_free(vr);
+ vr = NULL;
+ vrCount = 0;
}
diff --git a/plugins/Variables/src/variables.cpp b/plugins/Variables/src/variables.cpp index b5d91709b3..93ab27ab9d 100644 --- a/plugins/Variables/src/variables.cpp +++ b/plugins/Variables/src/variables.cpp @@ -36,8 +36,8 @@ HCURSOR hCurSplitNS; struct ParseOptions gParseOpts;
-TCHAR *getArguments(TCHAR *string, TCHAR ***aargv, int *aargc) {
-
+TCHAR* getArguments(TCHAR *string, TCHAR ***aargv, int *aargc)
+{
BOOL bDontParse, bNewArg, bDone;
TCHAR *cur, *scur, **argv;
int i, argc, brackets;
@@ -550,8 +550,8 @@ int LoadVarModule() return 0;
}
-int UnloadVarModule() {
-
+int UnloadVarModule()
+{
UnhookEvent(hOptionsHook);
if (hIconsChangedHook != NULL)
UnhookEvent(hIconsChangedHook);
diff --git a/plugins/Variables/src/variables.h b/plugins/Variables/src/variables.h index c8184a00ec..8818f1fdc7 100644 --- a/plugins/Variables/src/variables.h +++ b/plugins/Variables/src/variables.h @@ -178,32 +178,31 @@ int getContactFromString( CONTACTSINFO* ); int initContactModule();
int deinitContactModule();
// alias
-void registerAliasTokens();
+void registerAliasTokens();
void unregisterAliasTokens();
// system
-void registerSystemTokens();
+void registerSystemTokens();
// external
-void registerExternalTokens();
+void registerExternalTokens();
// miranda
-void registerMirandaTokens();
+void registerMirandaTokens();
// str
-void registerStrTokens();
+void registerStrTokens();
// variables
-void registerVariablesTokens();
+void registerVariablesTokens();
void unregisterVariablesTokens();
-int clearVariableRegister(bool bAll);
// logic
-void registerLogicTokens();
+void registerLogicTokens();
// math
-void registerMathTokens();
+void registerMathTokens();
// metacontacts
void registerMetaContactsTokens();
// options
int OptionsInit(WPARAM wParam, LPARAM);
// reg exp
-void registerRegExpTokens();
+void registerRegExpTokens();
// inet
-void registerInetTokens();
+void registerInetTokens();
// help
INT_PTR showHelpService(WPARAM wParam, LPARAM lParam);
INT_PTR showHelpExService(WPARAM wParam, LPARAM lParam);
|