diff --git a/include/mastodont_chats.h b/include/mastodont_chats.h index 705fc0a..528c07a 100644 --- a/include/mastodont_chats.h +++ b/include/mastodont_chats.h @@ -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 diff --git a/include/mastodont_emoji.h b/include/mastodont_emoji.h index 99fc2a2..708bcd3 100644 --- a/include/mastodont_emoji.h +++ b/include/mastodont_emoji.h @@ -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 */ diff --git a/src/chats.c b/src/chats.c index 901d3ca..5af0e40 100644 --- a/src/chats.c +++ b/src/chats.c @@ -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); +}