File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -6,8 +6,6 @@ import std::thread;
66import std ::net ;
77import std ::net ::tcp ;
88
9- // TODO FIX MEMORY LEAK
10-
119import std ::os ::win32 ;
1210
1311struct WsaData @if (env ::WIN32 ) {
@@ -40,8 +38,12 @@ import std::collections::map;
4038fn int process (void * arg ) {
4139//mem::@report_heap_allocs_in_scope() {
4240 TcpSocket * socket = arg ;
43- defer socket .close ()!! ;
44- defer allocator ::destroy_temp_allocators ();
41+
42+ defer {
43+ socket .close ()!! ;
44+ allocator ::free (& allocator ::LIBC_ALLOCATOR , arg );
45+ allocator ::destroy_temp_allocators ();
46+ }
4547
4648 HttpRequest req ;
4749 if (catch anyfault err = req .read (socket )) {
@@ -111,7 +113,7 @@ $endif
111113
112114 //mem::@report_heap_allocs_in_scope() {
113115 thread ::Thread thread ;
114- thread .create (& process , @tclone ( socket ))!! ;
116+ thread .create (& process , allocator :: clone ( & allocator :: LIBC_ALLOCATOR , socket ))!! ;
115117 thread .detach ()!! ;
116118 //};
117119 }
You can’t perform that action at this time.
0 commit comments