From 9974851d6c5f4b3e984a4b256e01bcb49e2c1918 Mon Sep 17 00:00:00 2001 From: Chip Black Date: Thu, 23 Dec 2010 23:50:24 -0600 Subject: [PATCH] Fix empty response for empty accounts --- http_blerg.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/http_blerg.c b/http_blerg.c index a73ac1e..9078f53 100644 --- a/http_blerg.c +++ b/http_blerg.c @@ -203,17 +203,13 @@ struct MHD_Response *create_response_for_range(struct blerg *b, uint64_t from, u return NULL; } - if (record_count == 0) { - response = MHD_create_response_from_data(2, "[]", MHD_NO, MHD_NO); - } else { - gs->entries = make_sequential_list(from, to); - gs->i = to - from; + gs->entries = make_sequential_list(from, to); + gs->i = to - from; - gs->g = yajl_gen_alloc(&yajl_c, NULL); - gs->yoff = gs->done = 0; + gs->g = yajl_gen_alloc(&yajl_c, NULL); + gs->yoff = gs->done = 0; - response = MHD_create_response_from_callback(-1, 262144, &GET_generate_list, gs, &GET_generate_list_free); - } + response = MHD_create_response_from_callback(-1, 262144, &GET_generate_list, gs, &GET_generate_list_free); return response; } @@ -262,7 +258,7 @@ ahc_derp (void *cls, struct MHD_Connection *connection, const char *url, const c uint64_t record_count, from, to; record_count = blerg_get_record_count(b); if (record_count == 0) { - response = create_response_for_range(b, 0, 0); + response = MHD_create_response_from_data(2, "[]", MHD_NO, MHD_NO); } else { to = record_count - 1; from = (record_count > 50 ? to - 49 : 0); -- 2.25.1