Fix chats cleanup

FossilOrigin-Name: 82b6217d30aa4781ce23d2e2ef02942d3932b9b3e689e689eb8c975cd84799ec
This commit is contained in:
nekobit 2022-08-25 00:59:59 +00:00
parent 8ffbec6620
commit e72613093e
2 changed files with 11 additions and 2 deletions

View file

@ -79,7 +79,8 @@ int mastodont_get_chat(mastodont_t* data,
struct mstdnt_storage* storage,
struct mstdnt_chat* chat);
void mstdnt_cleanup_chats(struct mstdnt_chat* chats);
void mstdnt_cleanup_chat(struct mstdnt_chat* chat);
void mstdnt_cleanup_chats(struct mstdnt_chat* chats, size_t len);
void mstdnt_cleanup_messages(struct mstdnt_message* chats);
#endif // MASTODONT_CHATS_H

View file

@ -199,9 +199,17 @@ int mastodont_get_chat(mastodont_t* data,
return mastodont_request(data, m_args, &req_args);
}
void mstdnt_cleanup_chats(struct mstdnt_chat* chats)
void mstdnt_cleanup_chat(struct mstdnt_chat* chat)
{
mstdnt_cleanup_account(&(chat->account));
}
void mstdnt_cleanup_chats(struct mstdnt_chat* chats, size_t len)
{
if (!chats) return;
for (size_t i = 0; i < len; ++i)
mstdnt_cleanup_chat(chats + i);
free(chats);
}