diff options
author | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2021-07-13 18:41:04 +0800 |
---|---|---|
committer | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2021-07-13 18:41:04 +0800 |
commit | 423b7a6d43efb07cd0124eb349f43ae7c7e04459 (patch) | |
tree | 39f1c74d52c5773735b65f9b8aa39887117a4b2e /pikul.c | |
parent | 1432293735a0a8e480939816c26b20335d636a42 (diff) |
Anticipate empty services array
There might be cases where there is the JSON object "services",
there's the array, but it's empty.
Diffstat (limited to 'pikul.c')
-rw-r--r-- | pikul.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -92,7 +92,7 @@ static int servicecmp(const void *service1, const void *service2) double pikul_cost(const char *origin, const char *destination, double weight, const char *code) { struct pikul_services *services = pikul_services(origin, destination, weight); - if (!services) + if (!services || !services->length) return .0; qsort(services->list, services->length, sizeof(struct pikul_service *), servicecmp); struct pikul_service *key_service = malloc(sizeof(struct pikul_service)); |