diff options
-rw-r--r-- | include/m_database.h | 2 | ||||
-rw-r--r-- | src/modules/database/dbutils.cpp | 11 |
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);
}
/////////////////////////////////////////////////////////////////////////////////////////
|