From 3dd44e9bd785d14bd867fa9ca9f17365238578c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=20=EA=A6=AB=EA=A6=B6=20=EA=A6=8F=EA=A7=80?= =?UTF-8?q?=EA=A6=A6=EA=A6=BF=20=EA=A6=A7=20=EA=A6=AE=20=EA=A6=91=20?= =?UTF-8?q?=EA=A6=A9=20=EA=A6=AD=EA=A7=80?= Date: Sun, 28 Jun 2020 20:42:51 +0800 Subject: Order init function --- client.c | 5 +---- icclient/ord.h | 1 + ord.c | 8 ++++++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/client.c b/client.c index 4bec7bb..61b4f4c 100644 --- a/client.c +++ b/client.c @@ -106,10 +106,7 @@ void icclient_order(icclient_ord_order **orderptr, const char *sku } else { *orderptr = malloc(sizeof(icclient_ord_order)); order = *orderptr; - order->subtotal = .0; - order->shipping = .0; - order->subtotal = .0; - order->nitems = 0; + icclient_ord_init(order); } if (item) diff --git a/icclient/ord.h b/icclient/ord.h index 5632ffe..638880a 100644 --- a/icclient/ord.h +++ b/icclient/ord.h @@ -18,6 +18,7 @@ struct icclient_ord_order { extern "C" { #endif + void icclient_ord_init(struct icclient_ord_order *order); void icclient_ord_free(struct icclient_ord_order *order); #ifdef __cplusplus diff --git a/ord.c b/ord.c index c1c2d4c..f59a4b9 100644 --- a/ord.c +++ b/ord.c @@ -3,6 +3,14 @@ #include "icclient/product.h" #include "icclient/ord.h" +void icclient_ord_init(struct icclient_ord_order *order) +{ + order->subtotal = .0; + order->shipping = .0; + order->subtotal = .0; + order->nitems = 0; +} + void icclient_ord_free(struct icclient_ord_order *order) { for (size_t i = 0; i < order->nitems; i++) -- cgit v1.2.3