From 89b7bef4c433bb42588eeec6e6f0d3d1c2a19b78 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: Sat, 5 Oct 2019 18:06:14 +0800 Subject: Separate the product structure definition so the catalog structure doesn't have to be included when not needed. product.c has too few implementations, so it's merged to client.c --- client.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'client.c') diff --git a/client.c b/client.c index 56dbf79..94de4c9 100644 --- a/client.c +++ b/client.c @@ -2,6 +2,7 @@ #include #include "login.h" #include "icclient/product.h" +#include "icclient/catalog.h" #include "icclient/client.h" typedef struct icclient_catalog icclient_catalog; @@ -65,6 +66,27 @@ void icclient_page(const char *path, size_t (*handler)(void *, size_t, size_t request(handler, (void *)dataptr, NULL, "%s", path); } +void icclient_freeproduct(struct icclient_product *product) +{ + if (product->image) + free(product->image); + if (product->comment) + free(product->comment); + if (product->description) + free(product->description); + free(product->sku); + free(product); + product = NULL; +} + +void icclient_freecatalog(icclient_catalog *catalog) +{ + for (size_t i = 0; i < catalog->length; i++) + icclient_freeproduct(catalog->products[i]); + free(catalog); + catalog = NULL; +} + void icclient_cleanup() { if (curl) { -- cgit v1.2.3