summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2023-05-19 17:21:13 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2023-05-19 17:21:13 +0800
commit62b3466160499345eb3bdcd1fa9a77500dbdeecd (patch)
treef6c8d22afc8631e5b259f20a31ae6bc23702e85f
parentb8680f8eecc7c7d4d3c09b6880904f3f732ea4d8 (diff)
Options might be gone at libinterchange
-rw-r--r--interchange.cxx16
1 files changed, 12 insertions, 4 deletions
diff --git a/interchange.cxx b/interchange.cxx
index c8c6a6e..1e3fc90 100644
--- a/interchange.cxx
+++ b/interchange.cxx
@@ -6,6 +6,7 @@ namespace QInterchange {
static Interchange* interchange;
static int sampleUrlLength = 0;
static char *mv_sku = nullptr, *mv_order_item = nullptr;
+ static QVector<const char *> pointers;
Interchange::Interchange(const char* sampleURL, const char* image_Dir,
const QString& cookie, const QString& certificate)
@@ -88,10 +89,16 @@ namespace QInterchange {
const char *mv_order_s[size + 1][2];
for (int i = 0; i < size; i++) {
auto pair = opts.at(i).toList();
- mv_order_s[i][0] = pair.at(0)
- .toByteArray().constData();
- mv_order_s[i][1] = pair.at(1)
- .toByteArray().constData();
+ auto key = pair.at(0).toByteArray();
+ mv_order_s[i][0] = (const char *)malloc(key.size() + 1);
+ strcpy(const_cast<char *>(mv_order_s[i][0]),
+ key.constData());
+ pointers.append(mv_order_s[i][0]);
+ auto val = pair.at(1).toByteArray();
+ mv_order_s[i][1] = (const char *)malloc(val.size() + 1);
+ strcpy(const_cast<char *>(mv_order_s[i][1]),
+ val.constData());
+ pointers.append(mv_order_s[i][1]);
}
mv_order_s[size][0] = nullptr;
interchange_ord_order(mv_sku, mv_order_item, quantity,
@@ -100,6 +107,7 @@ namespace QInterchange {
mv_sku = nullptr;
free(mv_order_item);
mv_order_item = nullptr;
+ for (auto pointer : pointers) free((void *)pointer);
interchange->emitOrder(QString{response->data});
interchange_free_response(response);
});