diff options
author | George Hazan <george.hazan@gmail.com> | 2016-09-17 17:51:01 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2016-09-17 17:51:01 +0000 |
commit | bf78f5c61903c55626ba3817155327cacdf3dcc8 (patch) | |
tree | cf722716c0c150130fa811bb713c70a08d66b5b4 | |
parent | d0735d50571bca069ee2fe372095b3750a32f51d (diff) |
crash fix
git-svn-id: http://svn.miranda-ng.org/main/trunk@17311 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/StatusPlugins/StartupStatus/options.cpp | 39 |
1 files changed, 11 insertions, 28 deletions
diff --git a/plugins/StatusPlugins/StartupStatus/options.cpp b/plugins/StatusPlugins/StartupStatus/options.cpp index d5a68121a0..87a969726b 100644 --- a/plugins/StatusPlugins/StartupStatus/options.cpp +++ b/plugins/StatusPlugins/StartupStatus/options.cpp @@ -488,45 +488,28 @@ static INT_PTR CALLBACK StartupStatusOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wPa }
///////////////////////////////////////////////////////////////////////////////
-
-static int CountSettings(const char *, LPARAM lParam)
-{
- *(int *)lParam++;
-
- return 0;
-}
-
// for db cleanup
-static int settingIndex;
static int DeleteSetting(const char *szSetting, LPARAM lParam)
{
- char** settings = *(char ***)lParam;
- settings[settingIndex] = (char*)malloc(mir_strlen(szSetting) + 1);
- mir_strcpy(settings[settingIndex], szSetting);
- settingIndex++;
-
+ LIST<char> *p = (LIST<char> *)lParam;
+ p->insert(mir_strdup(szSetting));
return 0;
}
static int ClearDatabase(char* filter)
{
- settingIndex = 0;
-
- int settingCount = 0;
- db_enum_settings(NULL, CountSettings, MODULENAME, &settingCount);
-
- char **settings = (char**)malloc(settingCount * sizeof(char*));
- db_enum_settings(NULL, DeleteSetting, MODULENAME, &settings);
+ LIST<char> arSettings(10);
+ db_enum_settings(NULL, DeleteSetting, MODULENAME, &arSettings);
- for (int i = 0; i < settingCount; i++) {
- if ((filter == NULL) || (!strncmp(filter, settings[i], mir_strlen(filter))))
- db_unset(NULL, MODULENAME, settings[i]);
- free(settings[i]);
+ for (int i = 0; i < arSettings.getCount(); i++) {
+ if ((filter == NULL) || (!strncmp(filter, arSettings[i], mir_strlen(filter))))
+ db_unset(NULL, MODULENAME, arSettings[i]);
+ mir_free(arSettings[i]);
}
- free(settings);
- // < v0.0.0.9
- if (filter == NULL) db_unset(NULL, "AutoAway", "Confirm");
+
+ if (filter == NULL)
+ db_unset(NULL, "AutoAway", "Confirm");
return 0;
}
|