summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2023-03-12 17:06:04 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2023-03-12 17:06:04 +0800
commite13451f98fab003c4cb883075053f9fb09b5c3b1 (patch)
tree9c4e51cfbed239912cdfc0b32ddbc12ad7c7ffee
parentd3d334e4769e28e20be2041103ae87620f3f7c96 (diff)
Not using pointers on products to avoid allocations
-rw-r--r--interchange.c3
-rw-r--r--interchange.h2
-rw-r--r--interchange/ord.h2
3 files changed, 3 insertions, 4 deletions
diff --git a/interchange.c b/interchange.c
index 55bbdd0..b173614 100644
--- a/interchange.c
+++ b/interchange.c
@@ -87,13 +87,12 @@ void interchange_free_product(struct interchange_product *product)
if (product->title)
free(product->title);
free(product->sku);
- free(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_free_product(&catalog->products[i]);
free(catalog);
}
diff --git a/interchange.h b/interchange.h
index 2ca9fb8..e890708 100644
--- a/interchange.h
+++ b/interchange.h
@@ -23,7 +23,7 @@ struct interchange_product {
struct interchange_catalog {
size_t length;
- struct interchange_product *products[];
+ struct interchange_product products[];
};
/*!
diff --git a/interchange/ord.h b/interchange/ord.h
index 2202243..d6ce999 100644
--- a/interchange/ord.h
+++ b/interchange/ord.h
@@ -4,7 +4,7 @@
#include "interchange/typedefs.h"
struct interchange_ord_item {
- struct interchange_product *product;
+ struct interchange_product product;
unsigned int quantity;
};