Check if statuses is empty
FossilOrigin-Name: b45be4aa14287d1a81f17b3e503383dd3d1427478bf8b0a1e9c6e7b25f8ae957
This commit is contained in:
parent
c40977c3f0
commit
ec5b72bdde
3 changed files with 7 additions and 6 deletions
1
1
1
1
|
@ -1 +0,0 @@
|
|||
make: *** No rule to make target '2'. Stop.
|
|
@ -123,7 +123,7 @@ int mastodont_request(mastodont_t* data, struct mastodont_request_args* args)
|
|||
storage->needs_cleanup = 1;
|
||||
|
||||
/* Optional */
|
||||
if (args->callback) args->callback(&results, storage, args->args);
|
||||
if (args->callback) res = args->callback(&results, storage, args->args);
|
||||
|
||||
cleanup_res:
|
||||
mastodont_fetch_results_cleanup(&results);
|
||||
|
|
10
src/status.c
10
src/status.c
|
@ -118,14 +118,16 @@ int mstdnt_statuses_from_result(struct mstdnt_storage* storage,
|
|||
{
|
||||
size_t i = 0;
|
||||
cJSON* root, *status_j_list;
|
||||
if (_mstdnt_json_init(&root, results, storage))
|
||||
return 1;
|
||||
|
||||
if (!cJSON_IsArray(root))
|
||||
if (_mstdnt_json_init(&root, results, storage) &&
|
||||
!cJSON_IsArray(root))
|
||||
return 1;
|
||||
|
||||
if (size) *size = cJSON_GetArraySize(root);
|
||||
|
||||
/* Statuses can be an empty array! */
|
||||
if (!(size ? *size : cJSON_GetArraySize(root)))
|
||||
return 0; /* Not an error, but we are done parsing */
|
||||
|
||||
/* malloc array - cJSON does a loop to count, let's do it once preferably */
|
||||
*statuses = calloc(1, (size ? *size : cJSON_GetArraySize(root))
|
||||
* sizeof(struct mstdnt_status));
|
||||
|
|
Loading…
Reference in a new issue