summaryrefslogtreecommitdiff
path: root/client.c
diff options
context:
space:
mode:
authorꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id>2019-10-05 18:06:14 +0800
committerꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id>2019-10-05 18:06:14 +0800
commit89b7bef4c433bb42588eeec6e6f0d3d1c2a19b78 (patch)
tree06e1c4e8373ea09bf683f21b277329279ae292bd /client.c
parentc5660800d60921392b66703b30dfc72d5f42d351 (diff)
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
Diffstat (limited to 'client.c')
-rw-r--r--client.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/client.c b/client.c
index 56dbf79..94de4c9 100644
--- a/client.c
+++ b/client.c
@@ -2,6 +2,7 @@
#include <stdlib.h>
#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) {