diff options
author | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2023-03-12 20:27:23 +0800 |
---|---|---|
committer | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2023-03-12 20:27:23 +0800 |
commit | aca2dbad31d1c7d76f08344244013c507d657222 (patch) | |
tree | 5fd8c003f50d60b5ca65828d7951ad829de2e7bb | |
parent | 7f0b0306514fc7187440998e183b9d6dfbaa2d01 (diff) |
Product & order free-ers are now clearers
-rw-r--r-- | interchange.c | 4 | ||||
-rw-r--r-- | interchange.h | 2 | ||||
-rw-r--r-- | interchange/ord.h | 2 | ||||
-rw-r--r-- | ord.c | 5 |
4 files changed, 7 insertions, 6 deletions
diff --git a/interchange.c b/interchange.c index b173614..8718e20 100644 --- a/interchange.c +++ b/interchange.c @@ -67,7 +67,7 @@ void interchange_page(const char *path, void (*handler)(interchange_response *)) request(handler, NULL, NULL, "%s", path); } -void interchange_free_product(struct interchange_product *product) +void interchange_clear_product(struct interchange_product *product) { if (product->crosssell) for (size_t i = 0; i < product->crosssell->length; i++) @@ -92,7 +92,7 @@ void interchange_free_product(struct interchange_product *product) void interchange_free_catalog(struct interchange_catalog *catalog) { for (size_t i = 0; i < catalog->length; i++) - interchange_free_product(&catalog->products[i]); + interchange_clear_product(&catalog->products[i]); free(catalog); } diff --git a/interchange.h b/interchange.h index e890708..2775613 100644 --- a/interchange.h +++ b/interchange.h @@ -65,7 +65,7 @@ void interchange_product(const char *sku, void (*handler)(interchange_response * void interchange_page(const char *path, void (*handler)(interchange_response *)); -void interchange_free_product(struct interchange_product *product); +void interchange_clear_product(struct interchange_product *product); void interchange_free_catalog(struct interchange_catalog *catalog); diff --git a/interchange/ord.h b/interchange/ord.h index ed7933d..d94c474 100644 --- a/interchange/ord.h +++ b/interchange/ord.h @@ -47,7 +47,7 @@ void interchange_ord_checkout(const char *order_profile, const struct interchange_member *member, void (*handler)(interchange_response *)); -void interchange_ord_free_order(struct interchange_ord_order *order); +void interchange_ord_clear_order(struct interchange_ord_order *order); void interchange_ord_free_transaction(struct interchange_ord_transaction *transaction); @@ -33,11 +33,12 @@ void interchange_ord_checkout(const char *order_profile, }}, "%s", "ord/checkout"); } -void interchange_ord_free_order(struct interchange_ord_order *order) +void interchange_ord_clear_order(struct interchange_ord_order *order) { + for (size_t i = 0; i < order->nitems; i++) + interchange_clear_product(&order->items[i].product); if (order->profile) free(order->profile); - free(order); } void interchange_ord_free_transaction(struct interchange_ord_transaction |