diff options
author | George Hazan <george.hazan@gmail.com> | 2025-01-24 19:59:18 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2025-01-24 19:59:18 +0300 |
commit | 5d1174129a88c6b527da0ebccfab3eff8d8474ac (patch) | |
tree | e9f933fe045af5aa3f11ce94368bdc955f23f6b7 /protocols/Weather/src/weather_update.cpp | |
parent | a3139fc57f7d7f6a2d0cbcd6a38041848f24d203 (diff) |
old shitty list removed
Diffstat (limited to 'protocols/Weather/src/weather_update.cpp')
-rw-r--r-- | protocols/Weather/src/weather_update.cpp | 39 |
1 files changed, 7 insertions, 32 deletions
diff --git a/protocols/Weather/src/weather_update.cpp b/protocols/Weather/src/weather_update.cpp index 7c90f73fcf..d0bd575629 100644 --- a/protocols/Weather/src/weather_update.cpp +++ b/protocols/Weather/src/weather_update.cpp @@ -221,16 +221,8 @@ int CWeatherProto::UpdateWeather(MCONTACT hContact) void CWeatherProto::UpdateListAdd(MCONTACT hContact) { - UPDATELIST *newItem = (UPDATELIST*)mir_alloc(sizeof(UPDATELIST)); - newItem->hContact = hContact; - newItem->next = nullptr; - mir_cslock lck(m_csUpdate); - if (UpdateListTail == nullptr) - UpdateListHead = newItem; - else - UpdateListTail->next = newItem; - UpdateListTail = newItem; + m_updateList.push_back(hContact); } // get the first item from the update queue and remove it from the queue @@ -238,35 +230,19 @@ void CWeatherProto::UpdateListAdd(MCONTACT hContact) MCONTACT CWeatherProto::UpdateGetFirst() { mir_cslock lck(m_csUpdate); - if (UpdateListHead == nullptr) + if (m_updateList.empty()) return 0; - UPDATELIST *Item = UpdateListHead; - - MCONTACT hContact = Item->hContact; - UpdateListHead = Item->next; - mir_free(Item); - - if (UpdateListHead == nullptr) - UpdateListTail = nullptr; - + auto it = m_updateList.begin(); + MCONTACT hContact = *it; + m_updateList.erase(it); return hContact; } void CWeatherProto::DestroyUpdateList(void) { mir_cslock lck(m_csUpdate); - - // free the list one by one - UPDATELIST *temp = UpdateListHead; - while (temp != nullptr) { - UpdateListHead = temp->next; - mir_free(temp); - temp = UpdateListHead; - } - - // make sure the entire list is clear - UpdateListTail = nullptr; + m_updateList.clear(); } ///////////////////////////////////////////////////////////////////////////////////////// @@ -283,7 +259,7 @@ void CWeatherProto::UpdateThread(void *) } // update weather by getting the first station from the queue until the queue is empty - while (UpdateListHead != nullptr && !Miranda_IsTerminated()) + while (!m_updateList.empty() && !Miranda_IsTerminated()) UpdateWeather(UpdateGetFirst()); // exit the update thread @@ -389,7 +365,6 @@ int CWeatherProto::GetWeatherData(MCONTACT hContact) if (Svc[0] == 0) return INVALID_SVC; uint16_t cond = NA; - char loc[256]; // download the html file from the internet wchar_t *szData = nullptr; |