summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-03-15 16:10:54 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-03-15 16:10:54 +0000
commit57308d4f9a9c181ec3b6231e946eba2300ee0472 (patch)
tree1bb0e7d82d4dcd180ccc9bb5ed4dfe984f4cfa62
parent91243d1c1d3b2360aab5b134c74dcb279a9136d7 (diff)
database event registration's code slightly enhanced
git-svn-id: http://svn.miranda-ng.org/main/trunk@8624 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--include/m_database.h2
-rw-r--r--src/modules/database/dbutils.cpp11
2 files changed, 4 insertions, 9 deletions
diff --git a/include/m_database.h b/include/m_database.h
index f2cb1b1eb8..6d1f18a29d 100644
--- a/include/m_database.h
+++ b/include/m_database.h
@@ -223,7 +223,7 @@ decode a blob and return the event text in the required format, its prototype is
to a call of MS_DB_EVENT_GETTEXT (see below)
wParam = 0
lParam = (LPARAM)(DBEVENTTYPEDESCR*)
-Always returns 0.
+Returns -1 on error (e.g., event type already registred), 0 on success
*/
typedef struct
diff --git a/src/modules/database/dbutils.cpp b/src/modules/database/dbutils.cpp
index d6bb468c29..7dacd223cd 100644
--- a/src/modules/database/dbutils.cpp
+++ b/src/modules/database/dbutils.cpp
@@ -42,10 +42,10 @@ static INT_PTR DbEventTypeRegister(WPARAM, LPARAM lParam)
{
DBEVENTTYPEDESCR *et = (DBEVENTTYPEDESCR*)lParam;
if (et == NULL || et->cbSize != sizeof(DBEVENTTYPEDESCR))
- return 0;
+ return -1;
if (eventTypes.getIndex(et) != -1)
- return 0;
+ return -1;
DBEVENTTYPEDESCR *p = (DBEVENTTYPEDESCR*)mir_calloc(sizeof(DBEVENTTYPEDESCR));
p->cbSize = sizeof(DBEVENTTYPEDESCR);
@@ -78,12 +78,7 @@ static INT_PTR DbEventTypeGet(WPARAM wParam, LPARAM lParam)
DBEVENTTYPEDESCR tmp;
tmp.module = (char*)wParam;
tmp.eventType = lParam;
-
- int idx;
- if (!List_GetIndex((SortedList*)&eventTypes, &tmp, &idx))
- return 0;
-
- return (INT_PTR)eventTypes[idx];
+ return (INT_PTR)eventTypes.find(&tmp);
}
/////////////////////////////////////////////////////////////////////////////////////////