Hand copies of ArrayBuffers where we have to
This commit is contained in:
parent
dabb0e9ebd
commit
88efc09f21
@ -106,8 +106,7 @@ struct HttpResponseWrapper {
|
|||||||
if (res) {
|
if (res) {
|
||||||
std::string_view ip = res->getRemoteAddress();
|
std::string_view ip = res->getRemoteAddress();
|
||||||
|
|
||||||
/* Todo: we need to pass a copy here */
|
args.GetReturnValue().Set(ArrayBuffer_NewCopy(isolate, (void *) ip.data(), ip.length()));
|
||||||
args.GetReturnValue().Set(ArrayBuffer_New(isolate, (void *) ip.data(), ip.length()/*, ArrayBufferCreationMode::kInternalized*/));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,8 +118,7 @@ struct HttpResponseWrapper {
|
|||||||
if (res) {
|
if (res) {
|
||||||
std::string_view ip = res->getRemoteAddressAsText();
|
std::string_view ip = res->getRemoteAddressAsText();
|
||||||
|
|
||||||
/* Todo: we need to pass a copy here */
|
args.GetReturnValue().Set(ArrayBuffer_NewCopy(isolate, (void *) ip.data(), ip.length()));
|
||||||
args.GetReturnValue().Set(ArrayBuffer_New(isolate, (void *) ip.data(), ip.length()/*, ArrayBufferCreationMode::kInternalized*/));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,8 +130,7 @@ struct HttpResponseWrapper {
|
|||||||
if (res) {
|
if (res) {
|
||||||
std::string_view ip = res->getProxiedRemoteAddress();
|
std::string_view ip = res->getProxiedRemoteAddress();
|
||||||
|
|
||||||
/* Todo: we need to pass a copy here */
|
args.GetReturnValue().Set(ArrayBuffer_NewCopy(isolate, (void *) ip.data(), ip.length()));
|
||||||
args.GetReturnValue().Set(ArrayBuffer_New(isolate, (void *) ip.data(), ip.length()/*, ArrayBufferCreationMode::kInternalized*/));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,8 +142,7 @@ struct HttpResponseWrapper {
|
|||||||
if (res) {
|
if (res) {
|
||||||
std::string_view ip = res->getProxiedRemoteAddressAsText();
|
std::string_view ip = res->getProxiedRemoteAddressAsText();
|
||||||
|
|
||||||
/* Todo: we need to pass a copy here */
|
args.GetReturnValue().Set(ArrayBuffer_NewCopy(isolate, (void *) ip.data(), ip.length()));
|
||||||
args.GetReturnValue().Set(ArrayBuffer_New(isolate, (void *) ip.data(), ip.length()/*, ArrayBufferCreationMode::kInternalized*/));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,12 @@ Local<v8::ArrayBuffer> ArrayBuffer_New(Isolate *isolate, void *data, size_t leng
|
|||||||
return ArrayBuffer::New(isolate, std::shared_ptr<BackingStore>(backingStore.release()));
|
return ArrayBuffer::New(isolate, std::shared_ptr<BackingStore>(backingStore.release()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Local<v8::ArrayBuffer> ArrayBuffer_NewCopy(Isolate *isolate, void *data, size_t length) {
|
||||||
|
Local<ArrayBuffer> ab = ArrayBuffer::New(isolate, length);
|
||||||
|
memcpy(ab->GetBackingStore()->Data(), data, length);
|
||||||
|
return ab;
|
||||||
|
}
|
||||||
|
|
||||||
struct PerSocketData {
|
struct PerSocketData {
|
||||||
UniquePersistent<Object> socketPf;
|
UniquePersistent<Object> socketPf;
|
||||||
};
|
};
|
||||||
|
@ -136,8 +136,7 @@ struct WebSocketWrapper {
|
|||||||
if (ws) {
|
if (ws) {
|
||||||
std::string_view ip = ws->getRemoteAddress();
|
std::string_view ip = ws->getRemoteAddress();
|
||||||
|
|
||||||
/* Todo: we need to pass a copy here */
|
args.GetReturnValue().Set(ArrayBuffer_NewCopy(isolate, (void *) ip.data(), ip.length()));
|
||||||
args.GetReturnValue().Set(ArrayBuffer_New(isolate, (void *) ip.data(), ip.length()/*, ArrayBufferCreationMode::kInternalized*/));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,8 +148,7 @@ struct WebSocketWrapper {
|
|||||||
if (ws) {
|
if (ws) {
|
||||||
std::string_view ip = ws->getRemoteAddressAsText();
|
std::string_view ip = ws->getRemoteAddressAsText();
|
||||||
|
|
||||||
/* Todo: we need to pass a copy here */
|
args.GetReturnValue().Set(ArrayBuffer_NewCopy(isolate, (void *) ip.data(), ip.length()));
|
||||||
args.GetReturnValue().Set(ArrayBuffer_New(isolate, (void *) ip.data(), ip.length()/*, ArrayBufferCreationMode::kInternalized*/));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,7 +246,6 @@ struct WebSocketWrapper {
|
|||||||
topicsArray->Set(isolate->GetCurrentContext(), topicsArray->Length(), topicString).IsNothing();
|
topicsArray->Set(isolate->GetCurrentContext(), topicsArray->Length(), topicString).IsNothing();
|
||||||
});
|
});
|
||||||
|
|
||||||
/* Todo: we need to pass a copy here */
|
|
||||||
args.GetReturnValue().Set(topicsArray);
|
args.GetReturnValue().Set(topicsArray);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user