7
7
8
8
#include " JSIHelper.h"
9
9
10
+ #include < utility>
11
+
10
12
using namespace std ;
11
13
using namespace facebook ;
12
14
@@ -27,7 +29,7 @@ QuickValue createTextQuickValue(string value)
27
29
{
28
30
return QuickValue{
29
31
.dataType = TEXT,
30
- .textValue = value};
32
+ .textValue = std::move ( value) };
31
33
}
32
34
33
35
QuickValue createIntegerQuickValue (int value)
@@ -58,12 +60,13 @@ QuickValue createDoubleQuickValue(double value)
58
60
.doubleOrIntValue = value};
59
61
}
60
62
61
- QuickValue createArrayBufferQuickValue ( uint8_t *arrayBufferValue, size_t arrayBufferSize)
63
+ QuickValue createArrayBufferQuickValueByCopying ( const uint8_t *arrayBufferValue, size_t arrayBufferSize)
62
64
{
65
+ vector<uint8_t > copy (arrayBufferValue, arrayBufferValue + arrayBufferSize);
66
+
63
67
return QuickValue{
64
68
.dataType = ARRAY_BUFFER,
65
- .arrayBufferValue = shared_ptr<uint8_t >{arrayBufferValue},
66
- .arrayBufferSize = arrayBufferSize};
69
+ .arrayBuffer = copy};
67
70
}
68
71
69
72
void jsiQueryArgumentsToSequelParam (jsi::Runtime &rt, jsi::Value const ¶ms, vector<QuickValue> *target)
@@ -116,7 +119,7 @@ void jsiQueryArgumentsToSequelParam(jsi::Runtime &rt, jsi::Value const ¶ms,
116
119
if (obj.isArrayBuffer (rt))
117
120
{
118
121
auto buf = obj.getArrayBuffer (rt);
119
- target->push_back (createArrayBufferQuickValue (buf.data (rt), buf.size (rt)));
122
+ target->push_back (createArrayBufferQuickValueByCopying (buf.data (rt), buf.size (rt)));
120
123
}
121
124
}
122
125
else
@@ -171,10 +174,10 @@ jsi::Value createSequelQueryExecutionResult(jsi::Runtime &rt, SQLiteOPResult sta
171
174
} else if (value.dataType == ARRAY_BUFFER)
172
175
{
173
176
jsi::Function array_buffer_ctor = rt.global ().getPropertyAsFunction (rt, " ArrayBuffer" );
174
- jsi::Object o = array_buffer_ctor.callAsConstructor (rt, (int ) value.arrayBufferSize ).getObject (rt);
177
+ jsi::Object o = array_buffer_ctor.callAsConstructor (rt, (int ) value.arrayBuffer . size () ).getObject (rt);
175
178
jsi::ArrayBuffer buf = o.getArrayBuffer (rt);
176
179
// It's a shame we have to copy here: see https://github.com/facebook/hermes/pull/419 and https://github.com/facebook/hermes/issues/564.
177
- memcpy (buf.data (rt), value.arrayBufferValue . get (), value.arrayBufferSize );
180
+ memcpy (buf.data (rt), value.arrayBuffer . data (), value.arrayBuffer . size () );
178
181
rowObject.setProperty (rt, columnName.c_str (), o);
179
182
} else
180
183
{
0 commit comments