diff --git a/include/mastodont_request.h b/include/mastodont_request.h index 0e1f94e..7cb3ebc 100644 --- a/include/mastodont_request.h +++ b/include/mastodont_request.h @@ -18,6 +18,7 @@ #include "mastodont.h" #include "mastodont_types.h" #include "mastodont_fetch.h" +#include "mastodont_query.h" struct mastodont_request_args { diff --git a/src/query.c b/src/query.c index 985bbf0..8761530 100644 --- a/src/query.c +++ b/src/query.c @@ -49,7 +49,7 @@ char* _mstdnt_query_string(mastodont_t* data, res_len = 0; char* result = malloc(res_len); if (src_l) - strncpy(result, src, res_len); + strcpy(result, src); /* We'll call them res to represent the query parameters */ int res_count = 0; @@ -71,7 +71,9 @@ char* _mstdnt_query_string(mastodont_t* data, } if (params[i].type != _MSTDNT_QUERY_ARRAY) + { key_ptr = params[i].key; + } if (key_ptr && !(params[i].type == _MSTDNT_QUERY_STRING && @@ -127,18 +129,20 @@ char* _mstdnt_query_string(mastodont_t* data, curl_free(escape_str); } - ++arr_ind; /* Finish array stuff */ if (params[i].type == _MSTDNT_QUERY_ARRAY) + { + ++arr_ind; + if (arr_ind >= params[i].value.a.arr_len) { arr_ind = 0; free(key_ptr); } else { - ++arr_ind; --i; /* Flip flop i */ } + } } return result;