int i;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Cleaning up\n");
+ if (NULL != handle->resp_object)
+ GNUNET_REST_jsonapi_object_delete (handle->resp_object);
if (NULL != handle->name)
GNUNET_free (handle->name);
if (NULL != handle->timeout_task)
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
- GNUNET_REST_jsonapi_object_delete (handle->resp_object);
resp = GNUNET_REST_create_json_response (result);
handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
GNUNET_free (result);
return GNUNET_SYSERR;
root_json = json_object ();
- if (0 == resp->res_count)
- {
- json_object_set (root_json, GNUNET_REST_JSONAPI_KEY_DATA, json_array());
- }
- else if (1 == resp->res_count)
- {
- json_object_set (root_json, GNUNET_REST_JSONAPI_KEY_DATA, resp->res_list_head->res_obj);
- }
- else
+ res_arr = json_array ();
+ for (res = resp->res_list_head;
+ res != NULL;
+ res = res->next)
{
- res_arr = json_array ();
- for (res = resp->res_list_head;
- res != NULL;
- res = res->next)
- {
- json_array_append (res_arr, res->res_obj);
- }
- json_object_set (root_json, GNUNET_REST_JSONAPI_KEY_DATA, res_arr);
+ json_array_append (res_arr, res->res_obj);
}
+ json_object_set (root_json, GNUNET_REST_JSONAPI_KEY_DATA, res_arr);
*result = json_dumps (root_json, JSON_INDENT(2));
+ json_decref (root_json);
+ json_decref (res_arr);
return GNUNET_OK;
}
* REST Utilities
*/
-/**
- * Check if namespace is in URL.
- *
- * @param url URL to check
- * @param namespace namespace to check against
- * @retun GNUNET_YES if namespace matches
- */
+ /**
+ * Check if namespace is in URL.
+ *
+ * @param url URL to check
+ * @param namespace namespace to check against
+ * @retun GNUNET_YES if namespace matches
+ */
int
GNUNET_REST_namespace_match (const char *url, const char *namespace)
{