diff options
author | George Hazan <george.hazan@gmail.com> | 2013-09-27 17:07:04 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-09-27 17:07:04 +0000 |
commit | 62e59387c15f062f16984cab024a0980a8503369 (patch) | |
tree | dc0640bcde3dd4f4c314fa289a3245c1891b479f /src/modules/extraicons/usedIcons.cpp | |
parent | 8a3b60207162ad0d6540531c6ede0696370b75b3 (diff) |
attempt to wipe out STL from extra icons
git-svn-id: http://svn.miranda-ng.org/main/trunk@6252 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules/extraicons/usedIcons.cpp')
-rw-r--r-- | src/modules/extraicons/usedIcons.cpp | 54 |
1 files changed, 25 insertions, 29 deletions
diff --git a/src/modules/extraicons/usedIcons.cpp b/src/modules/extraicons/usedIcons.cpp index 00f4e3f3c1..374f4bfb1c 100644 --- a/src/modules/extraicons/usedIcons.cpp +++ b/src/modules/extraicons/usedIcons.cpp @@ -25,37 +25,35 @@ Boston, MA 02111-1307, USA. struct Icon
{
- string name;
+ char *name;
int refCount;
HANDLE hImage;
Icon(const char *icolibName) :
- name(icolibName), refCount(0), hImage(INVALID_HANDLE_VALUE)
+ name( mir_strdup(icolibName)), refCount(0), hImage(INVALID_HANDLE_VALUE)
{
}
-};
-static vector<Icon> usedIcons;
+ ~Icon()
+ { mir_free(name);
+ }
+};
-static Icon* FindIcon(const char *icolibName)
+static int SortFunc(const Icon *p1, const Icon *p2)
{
- Icon *icon = NULL;
+ return strcmp(p1->name, p2->name);
+}
- for (unsigned int i = 0; i < usedIcons.size(); i++) {
- Icon *tmp = &usedIcons[i];
- if (tmp->name == icolibName) {
- icon = tmp;
- break;
- }
- }
+static OBJLIST<Icon> usedIcons(50, SortFunc);
- if (icon == NULL) {
- usedIcons.push_back( Icon(icolibName));
- icon = &usedIcons[usedIcons.size() - 1];
- }
+static Icon* FindIcon(const char *icolibName)
+{
+ Icon *icon = usedIcons.find((Icon*)&icolibName);
+ if (icon == NULL)
+ usedIcons.insert(icon = new Icon(icolibName));
if (icon->hImage == INVALID_HANDLE_VALUE) {
- HICON hIcon = Skin_GetIcon(icon->name.c_str());
+ HICON hIcon = Skin_GetIcon(icon->name);
if (hIcon != NULL) {
icon->hImage = ExtraIcon_Add(hIcon);
Skin_ReleaseIcon(hIcon);
@@ -79,14 +77,9 @@ HANDLE AddIcon(const char *icolibName) void RemoveIcon(const char *icolibName)
{
- for (unsigned int i = 0; i < usedIcons.size(); i++) {
- Icon *icon = &usedIcons[i];
- if (icon->name != icolibName)
- continue;
-
+ Icon *icon = usedIcons.find((Icon*)&icolibName);
+ if (icon != NULL)
icon->refCount--;
- break;
- }
}
static bool NotUsedIcon(const Icon &icon)
@@ -96,8 +89,11 @@ static bool NotUsedIcon(const Icon &icon) void ResetIcons()
{
- usedIcons.erase(std::remove_if(usedIcons.begin(), usedIcons.end(), NotUsedIcon), usedIcons.end());
-
- for (unsigned int i = 0; i < usedIcons.size(); i++)
- usedIcons[i].hImage = INVALID_HANDLE_VALUE;
+ for (int i = usedIcons.getCount()-1; i >= 0; i--) {
+ Icon &p = usedIcons[i];
+ if (p.refCount <= 0)
+ usedIcons.remove(i);
+ else
+ p.hImage = INVALID_HANDLE_VALUE;
+ }
}
|