Cleanup search results
FossilOrigin-Name: fb5fda3e58ff8ca0425cd82f4a0a49b115713c465ad0beccd606f45edc4ca486
This commit is contained in:
parent
988b495a35
commit
f2f9851015
6 changed files with 25 additions and 0 deletions
|
@ -107,5 +107,6 @@ void _mstdnt_val_malloc_account_call(cJSON* v, void* _type);
|
|||
|
||||
// Cleanup
|
||||
void mstdnt_cleanup_account(struct mstdnt_account* acct);
|
||||
void mstdnt_cleanup_accounts(struct mstdnt_account* accts, size_t len);
|
||||
|
||||
#endif /* MASTODONT_ACCOUNT */
|
||||
|
|
|
@ -60,4 +60,6 @@ int mastodont_search(mastodont_t* data,
|
|||
struct mstdnt_search_args* args,
|
||||
struct mstdnt_search_results* results);
|
||||
|
||||
void mstdnt_cleanup_search_results(struct mstdnt_search_results* res);
|
||||
|
||||
#endif /* MASTODONT_SEARCH_H */
|
||||
|
|
|
@ -187,5 +187,14 @@ MSTDNT_ACCOUNT_ACTION_FUNC_URL("unsubscribe")
|
|||
|
||||
void mstdnt_cleanup_account(struct mstdnt_account* acct)
|
||||
{
|
||||
if (!acct) return;
|
||||
cleanup_emojis(acct->emojis);
|
||||
}
|
||||
|
||||
void mstdnt_cleanup_accounts(struct mstdnt_account* accts, size_t len)
|
||||
{
|
||||
if (!accts) return;
|
||||
for (int i = 0; i < len; ++i)
|
||||
mstdnt_cleanup_account(accts + i);
|
||||
}
|
||||
|
||||
|
|
|
@ -107,6 +107,9 @@ char* _mstdnt_query_string(mastodont_t* data,
|
|||
val_ptr = escape_str;
|
||||
}
|
||||
|
||||
if (val_ptr == NULL)
|
||||
break;
|
||||
|
||||
/* Get lengths */
|
||||
key_len = strlen(key_ptr);
|
||||
val_len = strlen(val_ptr);
|
||||
|
|
|
@ -130,6 +130,8 @@ int mastodont_request(mastodont_t* data, struct mastodont_request_args* args)
|
|||
/* Optional */
|
||||
if (args->callback) res = args->callback(storage->root, args->args);
|
||||
}
|
||||
else
|
||||
res = 1;
|
||||
|
||||
cleanup_res:
|
||||
mastodont_fetch_results_cleanup(&results);
|
||||
|
|
|
@ -93,3 +93,11 @@ int mastodont_search(mastodont_t* data,
|
|||
|
||||
return mastodont_request(data, &req_args);
|
||||
}
|
||||
|
||||
void mstdnt_cleanup_search_results(struct mstdnt_search_results* res)
|
||||
{
|
||||
if (!res) return;
|
||||
mstdnt_cleanup_accounts(res->accts, res->accts_len);
|
||||
mstdnt_cleanup_statuses(res->statuses, res->statuses_len);
|
||||
mstdnt_cleanup_tags(res->tags, res->tags_len);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue