Account for arrays of pointers

FossilOrigin-Name: 0aecd3a06a469ef1635b4ba3bc33a2ecde1d9fd1b869a28ad9f83ec8680b6d4d
This commit is contained in:
me@ow.nekobit.net 2022-03-02 15:48:59 +00:00
parent 680b895807
commit 9ff1df3390
5 changed files with 23 additions and 6 deletions

View file

@ -38,7 +38,7 @@ struct mstdnt_emoji_reaction
};
void cleanup_emoji_reaction(struct mstdnt_emoji_reaction* reactions);
void cleanup_emoji_reactions(struct mstdnt_emoji_reaction* reactions);
void cleanup_emoji_reactions(struct mstdnt_emoji_reaction* reactions, size_t s);
void _mstdnt_val_emoji_reactions_call(cJSON* v, void* _type);
#endif /* MASTODONT_EMOJI */

View file

@ -114,6 +114,7 @@ struct mstdnt_create_status_args
char* visibility;
};
void cleanup_statuses(struct mstdnt_status* statuses, size_t s);
void cleanup_status(struct mstdnt_status* status);
int mstdnt_load_statuses_from_result(struct mstdnt_status* status[],

View file

@ -60,13 +60,17 @@ void _mstdnt_val_emoji_reactions_call(cJSON* v, void* _type)
}
}
void cleanup_emoji_reaction(struct mstdnt_emoji_reaction* reactions)
void cleanup_emoji_reaction(struct mstdnt_emoji_reaction* reaction)
{
/* NOP for compatibility purposes */
/* NOP, this will be implemented soon*/
return;
}
void cleanup_emoji_reactions(struct mstdnt_emoji_reaction* reactions)
void cleanup_emoji_reactions(struct mstdnt_emoji_reaction* reactions, size_t s)
{
if (reactions) free(reactions);
size_t i;
if (!reactions) return;
for (i = 0; i < s; ++i)
cleanup_emoji_reaction(reactions + s);
free(reactions);
}

View file

@ -50,6 +50,7 @@ void _mstdnt_val_status_pleroma_call(cJSON* v, void* _type)
void cleanup_status_pleroma(struct mstdnt_status_pleroma* pleroma)
{
cleanup_emoji_reactions(pleroma->emoji_reactions);
if (!pleroma) return;
cleanup_emoji_reactions(pleroma->emoji_reactions, pleroma->emoji_reactions_len);
}

View file

@ -345,3 +345,14 @@ void cleanup_status(struct mstdnt_status* status)
cleanup_attachments(status->media_attachments);
cleanup_status_pleroma(&(status->pleroma));
}
void cleanup_statuses(struct mstdnt_status* statuses, size_t s)
{
size_t i;
if (!statuses) return;
for (i = 0; i < s; ++i)
{
cleanup_status(statuses + i);
}
free(statuses);
}