Everywhere: Use slon_mem_task for memory allocation
This commit is contained in:
parent
5333b64917
commit
64f31de070
24 changed files with 146 additions and 139 deletions
|
@ -13,7 +13,7 @@ U32 @dns_query(U8* host)
|
|||
if (!host)
|
||||
return U32_MAX;
|
||||
DnsRequest* request = CAlloc(sizeof(DnsRequest), Fs->code_heap);
|
||||
request->host = StrNew(host, adam_task);
|
||||
request->host = StrNew(host, slon_mem_task);
|
||||
request->pointer_to_u32 = &res;
|
||||
U64* request_ptr = DNS_REQUEST_PTR;
|
||||
while (*request_ptr)
|
||||
|
|
|
@ -60,8 +60,8 @@ U0 md5(U8* initial_msg, U32 initial_len, U32* md5_h)
|
|||
;
|
||||
new_len /= 8;
|
||||
|
||||
msg = CAlloc(new_len + 64, adam_task); // also appends "0" bits
|
||||
// (we alloc also 64 extra bytes...)
|
||||
msg = CAlloc(new_len + 64, slon_mem_task); // also appends "0" bits
|
||||
// (we alloc also 64 extra bytes...)
|
||||
MemCpy(msg, initial_msg, initial_len);
|
||||
msg[initial_len] = 128; // write the "1" bit
|
||||
|
||||
|
@ -131,7 +131,7 @@ U8* md5_string(U8* buf, I64 size)
|
|||
{
|
||||
U32 md5_h[4];
|
||||
md5(buf, size, &md5_h[0]);
|
||||
U8* str = CAlloc(33, adam_task);
|
||||
U8* str = CAlloc(33, slon_mem_task);
|
||||
StrPrint(str + StrLen(str), "%02x%02x%02x%02x", md5_h[0].u8[0],
|
||||
md5_h[0].u8[1], md5_h[0].u8[2], md5_h[0].u8[3]);
|
||||
StrPrint(str + StrLen(str), "%02x%02x%02x%02x", md5_h[1].u8[0],
|
||||
|
|
|
@ -112,13 +112,13 @@ U0 @tcp_socket_close(TcpSocket* s)
|
|||
TcpSocket* @tcp_socket_create(U8* host, U64 port)
|
||||
{
|
||||
U64 addr = @dns_query(host);
|
||||
TcpSocket* s = CAlloc(sizeof(TcpSocket), adam_task->code_heap);
|
||||
TcpSocket* s = CAlloc(sizeof(TcpSocket), slon_mem_task->code_heap);
|
||||
s->remote_addr = addr;
|
||||
s->remote_port = port;
|
||||
|
||||
U64 a;
|
||||
|
||||
s->close = MAlloc(16, adam_task->code_heap);
|
||||
s->close = MAlloc(16, slon_mem_task->code_heap);
|
||||
MemCpy(s->close, @tcp_close_wrapper_function, 16);
|
||||
a = s->close;
|
||||
a += 0x05;
|
||||
|
@ -127,7 +127,7 @@ TcpSocket* @tcp_socket_create(U8* host, U64 port)
|
|||
a += 0x09;
|
||||
@patch_call_rel32(a, &@tcp_socket_close);
|
||||
|
||||
s->receive = MAlloc(25, adam_task->code_heap);
|
||||
s->receive = MAlloc(25, slon_mem_task->code_heap);
|
||||
MemCpy(s->receive, @tcp_receive_wrapper_function, 32);
|
||||
a = s->receive;
|
||||
a += 0x11;
|
||||
|
@ -136,7 +136,7 @@ TcpSocket* @tcp_socket_create(U8* host, U64 port)
|
|||
a += 0x15;
|
||||
@patch_call_rel32(a, &@tcp_socket_receive);
|
||||
|
||||
s->send = MAlloc(32, adam_task->code_heap);
|
||||
s->send = MAlloc(32, slon_mem_task->code_heap);
|
||||
MemCpy(s->send, @tcp_send_wrapper_function, 32);
|
||||
a = s->send;
|
||||
a += 0x11;
|
||||
|
@ -157,7 +157,7 @@ U64 @tcp_socket_bind(U64 port, U64 function)
|
|||
if (!port || !function)
|
||||
return NULL;
|
||||
|
||||
TcpBind* b = CAlloc(sizeof(TcpBind), adam_task->code_heap);
|
||||
TcpBind* b = CAlloc(sizeof(TcpBind), slon_mem_task->code_heap);
|
||||
b->port = port;
|
||||
b->function = function; // U0 my_spawn_wrapper_function(TcpSocket* s)
|
||||
|
||||
|
@ -179,7 +179,7 @@ TcpSocket* @tcp_socket_accept(TcpSocket* s)
|
|||
|
||||
U64 a;
|
||||
|
||||
s->close = MAlloc(16, adam_task->code_heap);
|
||||
s->close = MAlloc(16, slon_mem_task->code_heap);
|
||||
MemCpy(s->close, @tcp_close_wrapper_function, 16);
|
||||
a = s->close;
|
||||
a += 0x05;
|
||||
|
@ -188,7 +188,7 @@ TcpSocket* @tcp_socket_accept(TcpSocket* s)
|
|||
a += 0x09;
|
||||
@patch_call_rel32(a, &@tcp_socket_close);
|
||||
|
||||
s->receive = MAlloc(25, adam_task->code_heap);
|
||||
s->receive = MAlloc(25, slon_mem_task->code_heap);
|
||||
MemCpy(s->receive, @tcp_receive_wrapper_function, 32);
|
||||
a = s->receive;
|
||||
a += 0x11;
|
||||
|
@ -197,7 +197,7 @@ TcpSocket* @tcp_socket_accept(TcpSocket* s)
|
|||
a += 0x15;
|
||||
@patch_call_rel32(a, &@tcp_socket_receive);
|
||||
|
||||
s->send = MAlloc(32, adam_task->code_heap);
|
||||
s->send = MAlloc(32, slon_mem_task->code_heap);
|
||||
MemCpy(s->send, @tcp_send_wrapper_function, 32);
|
||||
a = s->send;
|
||||
a += 0x11;
|
||||
|
|
|
@ -50,13 +50,13 @@ U0 @tls12_connect(TlsSocket* s)
|
|||
TlsSocket* @tls_socket_create(U8* server_name, U64 port = 443)
|
||||
{
|
||||
U64 addr = @dns_query(server_name);
|
||||
TlsSocket* s = CAlloc(sizeof(TlsSocket), adam_task->code_heap);
|
||||
TlsSocket* s = CAlloc(sizeof(TlsSocket), slon_mem_task->code_heap);
|
||||
s->remote_addr = addr;
|
||||
s->remote_port = port;
|
||||
|
||||
U64 a;
|
||||
|
||||
s->close = MAlloc(16, adam_task->code_heap);
|
||||
s->close = MAlloc(16, slon_mem_task->code_heap);
|
||||
MemCpy(s->close, @tcp_close_wrapper_function, 16);
|
||||
a = s->close;
|
||||
a += 0x05;
|
||||
|
@ -65,7 +65,7 @@ TlsSocket* @tls_socket_create(U8* server_name, U64 port = 443)
|
|||
a += 0x09;
|
||||
@patch_call_rel32(a, &@tcp_socket_close);
|
||||
|
||||
s->receive = MAlloc(25, adam_task->code_heap);
|
||||
s->receive = MAlloc(25, slon_mem_task->code_heap);
|
||||
MemCpy(s->receive, @tcp_receive_wrapper_function, 32);
|
||||
a = s->receive;
|
||||
a += 0x11;
|
||||
|
@ -74,7 +74,7 @@ TlsSocket* @tls_socket_create(U8* server_name, U64 port = 443)
|
|||
a += 0x15;
|
||||
@patch_call_rel32(a, &@tls_socket_receive);
|
||||
|
||||
s->send = MAlloc(32, adam_task->code_heap);
|
||||
s->send = MAlloc(32, slon_mem_task->code_heap);
|
||||
MemCpy(s->send, @tcp_send_wrapper_function, 32);
|
||||
a = s->send;
|
||||
a += 0x11;
|
||||
|
@ -92,7 +92,7 @@ TlsSocket* @tls_socket_create(U8* server_name, U64 port = 443)
|
|||
Sleep(1);
|
||||
|
||||
s->ctx = @tls_create_context(0, TLS_V12);
|
||||
@tls_sni_set(s->ctx, StrNew(server_name, adam_task->code_heap));
|
||||
@tls_sni_set(s->ctx, StrNew(server_name, slon_mem_task->code_heap));
|
||||
Spawn(&@tls12_connect, s, , , , TLS_CONNECT_TASK_STACK_SIZE);
|
||||
|
||||
return s;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue