X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;f=http_blerg.c;h=9078f5352d54096980f31688b64e97b72a86ac32;hb=9974851d6c5f4b3e984a4b256e01bcb49e2c1918;hp=a73ac1e80b125609bab091a59466d4323b418fc5;hpb=268230019ea44f384c6c0b34df71fbcdcb3602fc;p=blerg.git 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);