diff --git a/samples/ffi/http/lib/fake_http.cc b/samples/ffi/http/lib/fake_http.cc index 21a29875bd5..63b4f1d3853 100644 --- a/samples/ffi/http/lib/fake_http.cc +++ b/samples/ffi/http/lib/fake_http.cc @@ -34,7 +34,7 @@ Content-Type: text/html; charset=UTF-8 DART_EXPORT void http_get(const char* uri, void (*onResponse)(const char*)) { std::thread([onResponse]() { std::this_thread::sleep_for(std::chrono::seconds(3)); - onResponse(strdup(kExampleResponse)); + onResponse(kExampleResponse); }).detach(); } @@ -42,7 +42,7 @@ DART_EXPORT void http_serve(void (*onRequest)(const char*)) { std::thread([onRequest]() { while (true) { std::this_thread::sleep_for(std::chrono::seconds(1)); - onRequest(strdup(kExampleRequest)); + onRequest(kExampleRequest); } }).detach(); } diff --git a/samples/ffi/http/lib/http.dart b/samples/ffi/http/lib/http.dart index 1fde486f72c..0ce55c2ede4 100644 --- a/samples/ffi/http/lib/http.dart +++ b/samples/ffi/http/lib/http.dart @@ -17,7 +17,6 @@ Future httpGet(String uri) async { final completer = Completer(); void onResponse(Pointer responsePointer) { completer.complete(responsePointer.toDartString()); - calloc.free(responsePointer); } final callback = NativeCallable.listener(onResponse); @@ -44,7 +43,6 @@ void httpServe(void Function(String) onRequest) { // Create the NativeCallable.listener. void onNativeRequest(Pointer requestPointer) { onRequest(requestPointer.toDartString()); - calloc.free(requestPointer); } final callback = NativeCallable.listener(onNativeRequest);