summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id>2020-06-20 11:41:01 +0800
committerꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id>2020-06-20 11:41:01 +0800
commit63b109ca1c1c54319d164ddcfa5760aa66558ccd (patch)
tree6904b1c8fa0a4109b0734ebc6067f5aa9af22490
parentfdb6565f877a33aa95afc24d937650095cbd6e4d (diff)
Move catalog freeing implementation to catalog's own implementation
-rw-r--r--Makefile.am1
-rw-r--r--catalog.c11
-rw-r--r--client.c8
-rw-r--r--icclient/catalog.h10
-rw-r--r--icclient/client.h1
5 files changed, 22 insertions, 9 deletions
diff --git a/Makefile.am b/Makefile.am
index 0ac0146..5f94fbb 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4,6 +4,7 @@ libicclient_la_SOURCES = \
request.h \
request.c \
product.c \
+ catalog.c \
ord.c \
login.h \
login.c \
diff --git a/catalog.c b/catalog.c
new file mode 100644
index 0000000..27e2385
--- /dev/null
+++ b/catalog.c
@@ -0,0 +1,11 @@
+#include <stdlib.h>
+#include "icclient/product.h"
+#include "icclient/catalog.h"
+
+void icclient_catalog_free(struct icclient_catalog *catalog)
+{
+ for (size_t i = 0; i < catalog->length; i++)
+ icclient_product_free(catalog->products[i]);
+ free(catalog);
+ catalog = NULL;
+}
diff --git a/client.c b/client.c
index 604e849..3e92aff 100644
--- a/client.c
+++ b/client.c
@@ -167,14 +167,6 @@ void icclient_page(const char *path, size_t (*handler)(void *, size_t, size_t
request(handler, (void *)dataptr, NULL, "%s", path);
}
-void icclient_freecatalog(icclient_catalog *catalog)
-{
- for (size_t i = 0; i < catalog->length; i++)
- icclient_product_free(catalog->products[i]);
- free(catalog);
- catalog = NULL;
-}
-
void icclient_cleanup()
{
if (curl) {
diff --git a/icclient/catalog.h b/icclient/catalog.h
index b38434b..ee65c1e 100644
--- a/icclient/catalog.h
+++ b/icclient/catalog.h
@@ -6,4 +6,14 @@ struct icclient_catalog {
struct icclient_product *products[];
};
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ void icclient_catalog_free(struct icclient_catalog *catalog);
+
+#ifdef __cplusplus
+}
+#endif
+
#endif // ICCLIENT_CATALOG_H
diff --git a/icclient/client.h b/icclient/client.h
index 4a9ac6a..02804bb 100644
--- a/icclient/client.h
+++ b/icclient/client.h
@@ -73,7 +73,6 @@ extern "C" {
size_t (*handler)(void *contents, size_t size,
size_t nmemb, void *userdata),
void **dataptr);
- void icclient_freecatalog(struct icclient_catalog *catalog);
void icclient_cleanup();
#ifdef __cplusplus