Cleanup for chats and messages

FossilOrigin-Name: feb547532ff56ae417b5fcece92f59f11fa6d51790b5d618425080dc4d8631fa
This commit is contained in:
nekobit 2022-08-25 00:05:14 +00:00
parent 004c06b5d7
commit fc90409c7f
3 changed files with 19 additions and 0 deletions

View file

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

View file

@ -47,6 +47,7 @@ void _mstdnt_val_emojis_call(cJSON* v, void* _type);
void _mstdnt_val_emoji_reactions_call(cJSON* v, void* _type);
void cleanup_emoji_reaction(struct mstdnt_emoji_reaction* reactions);
void cleanup_emoji_reactions(struct mstdnt_emoji_reaction* reactions, size_t s);
// TODO add length for compatibility
void cleanup_emojis(struct mstdnt_emoji* emo);
#endif /* MASTODONT_EMOJI */

View file

@ -197,3 +197,18 @@ int mastodont_get_chat(mastodont_t* data,
return mastodont_request(data, m_args, &req_args);
}
void mstdnt_cleanup_chats(struct mstdnt_chat* chats, size_t chats_len)
{
// Unused for compatibility
(void)chats_len;
if (!chats) return;
free(chats);
}
void mstdnt_cleanup_messages(struct mstdnt_message* messages, size_t messages_len)
{
(void)messages_len;
if (!chats) return;
mstdnt_cleanup_emojis(messages->emojis);
}