File tree Expand file tree Collapse file tree 2 files changed +2
-4
lines changed Expand file tree Collapse file tree 2 files changed +2
-4
lines changed Original file line number Diff line number Diff line change @@ -34,15 +34,15 @@ Content-Type: text/html; charset=UTF-8
34
34
DART_EXPORT void http_get (const char * uri, void (*onResponse)(const char *)) {
35
35
std::thread ([onResponse]() {
36
36
std::this_thread::sleep_for (std::chrono::seconds (3 ));
37
- onResponse (strdup ( kExampleResponse ) );
37
+ onResponse (kExampleResponse );
38
38
}).detach ();
39
39
}
40
40
41
41
DART_EXPORT void http_serve (void (*onRequest)(const char *)) {
42
42
std::thread ([onRequest]() {
43
43
while (true ) {
44
44
std::this_thread::sleep_for (std::chrono::seconds (1 ));
45
- onRequest (strdup ( kExampleRequest ) );
45
+ onRequest (kExampleRequest );
46
46
}
47
47
}).detach ();
48
48
}
Original file line number Diff line number Diff line change @@ -17,7 +17,6 @@ Future<String> httpGet(String uri) async {
17
17
final completer = Completer <String >();
18
18
void onResponse (Pointer <Utf8 > responsePointer) {
19
19
completer.complete (responsePointer.toDartString ());
20
- calloc.free (responsePointer);
21
20
}
22
21
23
22
final callback = NativeCallable <HttpCallback >.listener (onResponse);
@@ -44,7 +43,6 @@ void httpServe(void Function(String) onRequest) {
44
43
// Create the NativeCallable.listener.
45
44
void onNativeRequest (Pointer <Utf8 > requestPointer) {
46
45
onRequest (requestPointer.toDartString ());
47
- calloc.free (requestPointer);
48
46
}
49
47
50
48
final callback = NativeCallable <HttpCallback >.listener (onNativeRequest);
You can’t perform that action at this time.
0 commit comments