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
|
@ -296,9 +296,9 @@ U0 @slon_api_v1_accounts_patch(SlonHttpSession* session)
|
|||
FileWrite(scratch_buffer, file->buffer, file->size);
|
||||
@slon_free(session, media_id);
|
||||
// Then, async upload the image file to Catbox
|
||||
cb = CAlloc(sizeof(SlonCatboxUpload), adam_task);
|
||||
cb = CAlloc(sizeof(SlonCatboxUpload), slon_mem_task);
|
||||
cb->key = acct->@("avatar", TRUE);
|
||||
cb->filepath = StrNew(scratch_buffer, adam_task);
|
||||
cb->filepath = StrNew(scratch_buffer, slon_mem_task);
|
||||
cb->callback = &@slon_db_actors_update_user;
|
||||
cb->callback_arg = acct;
|
||||
Spawn(&@slon_api_async_upload_to_catbox, cb, "SlonAsyncCatboxUpload");
|
||||
|
@ -316,9 +316,9 @@ U0 @slon_api_v1_accounts_patch(SlonHttpSession* session)
|
|||
FileWrite(scratch_buffer, file->buffer, file->size);
|
||||
@slon_free(session, media_id);
|
||||
// Then, async upload the image file to Catbox
|
||||
cb = CAlloc(sizeof(SlonCatboxUpload), adam_task);
|
||||
cb = CAlloc(sizeof(SlonCatboxUpload), slon_mem_task);
|
||||
cb->key = acct->@("header", TRUE);
|
||||
cb->filepath = StrNew(scratch_buffer, adam_task);
|
||||
cb->filepath = StrNew(scratch_buffer, slon_mem_task);
|
||||
cb->callback = &@slon_db_actors_update_user;
|
||||
cb->callback_arg = acct;
|
||||
Spawn(&@slon_api_async_upload_to_catbox, cb, "SlonAsyncCatboxUpload");
|
||||
|
|
|
@ -133,7 +133,7 @@ U0 @slon_api_v1_statuses_delete(SlonHttpSession* session)
|
|||
while (*(attachment_url_ptr - 1) != '/') {
|
||||
--attachment_url_ptr;
|
||||
}
|
||||
Spawn(&@slon_api_async_delete_from_catbox, StrNew(attachment_url_ptr, adam_task), "SlonAsyncCatboxDelete");
|
||||
Spawn(&@slon_api_async_delete_from_catbox, StrNew(attachment_url_ptr, slon_mem_task), "SlonAsyncCatboxDelete");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,9 +51,9 @@ U0 @slon_api_v2_media_post(SlonHttpSession* session)
|
|||
db->o("media")->set(media_id, media_object, JSON_OBJECT);
|
||||
|
||||
// Then, async upload the image file to Catbox
|
||||
SlonCatboxUpload* cb = CAlloc(sizeof(SlonCatboxUpload), adam_task);
|
||||
SlonCatboxUpload* cb = CAlloc(sizeof(SlonCatboxUpload), slon_mem_task);
|
||||
cb->key = media_object->@("url", TRUE);
|
||||
cb->filepath = StrNew(scratch_buffer, adam_task);
|
||||
cb->filepath = StrNew(scratch_buffer, slon_mem_task);
|
||||
Spawn(&@slon_api_async_upload_to_catbox, cb, "SlonAsyncCatboxUpload");
|
||||
|
||||
session->send(media_object);
|
||||
|
|
|
@ -27,7 +27,7 @@ JsonObject* @slon_api_v2_search_remote_account_from_webfinger(SlonHttpSession* s
|
|||
return NULL;
|
||||
}
|
||||
|
||||
U8* fetch_buffer = CAlloc(HTTP_FETCH_BUFFER_SIZE, adam_task);
|
||||
U8* fetch_buffer = CAlloc(HTTP_FETCH_BUFFER_SIZE, slon_mem_task);
|
||||
JsonObject* http_headers = Json.CreateObject();
|
||||
http_headers->set("accept", "application/json", JSON_STRING);
|
||||
@http_response* resp = Http.Get(url, fetch_buffer, NULL, http_headers);
|
||||
|
@ -78,7 +78,7 @@ JsonObject* @slon_api_v2_search_remote_account_from_webfinger(SlonHttpSession* s
|
|||
}
|
||||
|
||||
// We have the remote actor uri, let's fetch and create a local account
|
||||
fetch_buffer = CAlloc(HTTP_FETCH_BUFFER_SIZE, adam_task);
|
||||
fetch_buffer = CAlloc(HTTP_FETCH_BUFFER_SIZE, slon_mem_task);
|
||||
U8* signatory = db->o("actors")->o(@slon_api_account_by_id(account_id)->@("username"))->@("id");
|
||||
resp = @slon_activitypub_signed_request(remote_actor, fetch_buffer, NULL, SLON_HTTP_VERB_GET, signatory);
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ SlonHttpResponse* @slon_http_init_response(SlonHttpSession* session)
|
|||
|
||||
SlonHttpSession* @slon_http_init_session(TcpSocket* s)
|
||||
{
|
||||
SlonHttpSession* session = CAlloc(sizeof(SlonHttpSession), adam_task);
|
||||
SlonHttpSession* session = CAlloc(sizeof(SlonHttpSession), slon_mem_task);
|
||||
session->bytes_used = MSize2(session);
|
||||
session->s = s;
|
||||
session->request = @slon_http_init_request(session);
|
||||
|
@ -87,7 +87,7 @@ SlonHttpSession* @slon_http_init_session(TcpSocket* s)
|
|||
// Create a copy of function and patch status
|
||||
U64 a;
|
||||
I64 code_size = MSize(&@slon_session_status_wrapper_function);
|
||||
session->status = CAlloc(code_size, adam_task->code_heap);
|
||||
session->status = CAlloc(code_size, slon_mem_task->code_heap);
|
||||
MemCpy(session->status, &@slon_session_status_wrapper_function, code_size);
|
||||
|
||||
a = session->status;
|
||||
|
@ -96,7 +96,7 @@ SlonHttpSession* @slon_http_init_session(TcpSocket* s)
|
|||
|
||||
// Create a copy of function and patch header
|
||||
code_size = MSize(&@slon_session_header_wrapper_function);
|
||||
session->header = CAlloc(code_size, adam_task->code_heap);
|
||||
session->header = CAlloc(code_size, slon_mem_task->code_heap);
|
||||
MemCpy(session->header, &@slon_session_header_wrapper_function, code_size);
|
||||
|
||||
a = session->header;
|
||||
|
@ -113,7 +113,7 @@ SlonHttpSession* @slon_http_init_session(TcpSocket* s)
|
|||
|
||||
// Create a copy of function and patch send
|
||||
code_size = MSize(&@slon_session_send_wrapper_function);
|
||||
session->send = CAlloc(code_size, adam_task->code_heap);
|
||||
session->send = CAlloc(code_size, slon_mem_task->code_heap);
|
||||
MemCpy(session->send, &@slon_session_send_wrapper_function, code_size);
|
||||
|
||||
a = session->send;
|
||||
|
@ -134,7 +134,7 @@ SlonHttpSession* @slon_http_init_session(TcpSocket* s)
|
|||
|
||||
// Create a copy of function and patch verb
|
||||
code_size = MSize(&@slon_session_verb_wrapper_function);
|
||||
session->verb = CAlloc(code_size, adam_task->code_heap);
|
||||
session->verb = CAlloc(code_size, slon_mem_task->code_heap);
|
||||
MemCpy(session->verb, &@slon_session_verb_wrapper_function, code_size);
|
||||
|
||||
a = session->verb;
|
||||
|
@ -147,7 +147,7 @@ SlonHttpSession* @slon_http_init_session(TcpSocket* s)
|
|||
|
||||
// Create a copy of function and patch path
|
||||
code_size = MSize(&@slon_session_path_wrapper_function);
|
||||
session->path = CAlloc(code_size, adam_task->code_heap);
|
||||
session->path = CAlloc(code_size, slon_mem_task->code_heap);
|
||||
MemCpy(session->path, &@slon_session_path_wrapper_function, code_size);
|
||||
|
||||
a = session->path;
|
||||
|
@ -160,7 +160,7 @@ SlonHttpSession* @slon_http_init_session(TcpSocket* s)
|
|||
|
||||
// Create a copy of function and patch path_count
|
||||
code_size = MSize(&@slon_session_path_count_wrapper_function);
|
||||
session->path_count = CAlloc(code_size, adam_task->code_heap);
|
||||
session->path_count = CAlloc(code_size, slon_mem_task->code_heap);
|
||||
MemCpy(session->path_count, &@slon_session_path_count_wrapper_function, code_size);
|
||||
|
||||
a = session->path_count;
|
||||
|
@ -169,7 +169,7 @@ SlonHttpSession* @slon_http_init_session(TcpSocket* s)
|
|||
|
||||
// Create a copy of function and patch content_type
|
||||
code_size = MSize(&@slon_session_content_type_wrapper_function);
|
||||
session->content_type = CAlloc(code_size, adam_task->code_heap);
|
||||
session->content_type = CAlloc(code_size, slon_mem_task->code_heap);
|
||||
MemCpy(session->content_type, &@slon_session_content_type_wrapper_function, code_size);
|
||||
|
||||
a = session->content_type;
|
||||
|
@ -439,7 +439,7 @@ JsonObject* @slon_http_json_object_from_multipart_form_data(SlonHttpSession* ses
|
|||
U8 scratch_buffer[256];
|
||||
|
||||
SlonMultipartParser* mp = @slon_calloc(session, sizeof(SlonMultipartParser));
|
||||
mp->consumed = FifoU8New(2048, adam_task);
|
||||
mp->consumed = FifoU8New(2048, slon_mem_task);
|
||||
|
||||
JsonObject* obj = Json.CreateObject();
|
||||
U8* boundary = StrFind("boundary=", session->header("content-type")) + 9;
|
||||
|
|
|
@ -109,7 +109,7 @@ Bool @slon_activitypub_http_signature_is_valid(SlonHttpSession* session, U8* use
|
|||
U8* signatory_url_string = @slon_strnew(session, keyId);
|
||||
StrFind("#", signatory_url_string)[0] = NULL;
|
||||
|
||||
U8* fetch_buffer = CAlloc(HTTP_FETCH_BUFFER_SIZE, adam_task);
|
||||
U8* fetch_buffer = CAlloc(HTTP_FETCH_BUFFER_SIZE, slon_mem_task);
|
||||
U8* signatory = db->o("actors")->o(user)->@("id");
|
||||
@http_response* resp = @slon_activitypub_signed_request(signatory_url_string, fetch_buffer, NULL, SLON_HTTP_VERB_GET, signatory);
|
||||
@slon_free(session, signatory_url_string);
|
||||
|
@ -230,7 +230,7 @@ Bool @slon_activitypub_http_signature_is_valid(SlonHttpSession* session, U8* use
|
|||
calc_sha_256(sig_string_hash, sig_string, StrLen(sig_string));
|
||||
|
||||
// Import RSA key
|
||||
U64 rsa_key = CAlloc(sizeof(U64) * 32, adam_task);
|
||||
U64 rsa_key = CAlloc(sizeof(U64) * 32, slon_mem_task);
|
||||
I64 res = @rsa_import(db->o("public_keys")->o(keyId)->@("key"), db->o("public_keys")->o(keyId)->@("length"), rsa_key);
|
||||
if (res != 0) { // CRYPT_OK = 0
|
||||
@slon_log(LOG_HTTPD, "Received error from @rsa_import: %d", res);
|
||||
|
@ -348,7 +348,7 @@ U0 @slon_activitypub_users_get(SlonHttpSession* session)
|
|||
I64 res;
|
||||
|
||||
// Import RSA key
|
||||
U64 rsa_key = CAlloc(sizeof(U64) * 32, adam_task);
|
||||
U64 rsa_key = CAlloc(sizeof(U64) * 32, slon_mem_task);
|
||||
res = @rsa_import(private_key_binary->@("data"), private_key_binary->@("size"), rsa_key);
|
||||
AdamLog("@rsa_import: res: %d\n", res);
|
||||
|
||||
|
@ -423,7 +423,7 @@ U0 @slon_activitypub_async_accept_request(JsonObject* o)
|
|||
accept_object->set("actor", this_actor, JSON_STRING);
|
||||
accept_object->set("object", request, JSON_OBJECT);
|
||||
|
||||
U8* fetch_buffer = CAlloc(HTTP_FETCH_BUFFER_SIZE, adam_task);
|
||||
U8* fetch_buffer = CAlloc(HTTP_FETCH_BUFFER_SIZE, slon_mem_task);
|
||||
StrPrint(scratch_buffer, "%s/inbox", o->@("actor_for_key_id"));
|
||||
@slon_activitypub_signed_request(scratch_buffer, fetch_buffer, accept_object);
|
||||
Free(fetch_buffer);
|
||||
|
@ -437,7 +437,7 @@ U0 @slon_activitypub_async_create_status_to(JsonObject* status, U8* dest)
|
|||
|
||||
U8 scratch_buffer[2048];
|
||||
|
||||
U8* this_actor = StrNew(status->@("uri"), adam_task);
|
||||
U8* this_actor = StrNew(status->@("uri"), slon_mem_task);
|
||||
StrFind("/statuses/", this_actor)[0] = NULL;
|
||||
|
||||
JsonObject* create_object = Json.CreateObject();
|
||||
|
@ -505,7 +505,7 @@ U0 @slon_activitypub_async_create_status_to(JsonObject* status, U8* dest)
|
|||
note_object->set("shares", SLON_EMPTY_JSON_OBJECT, JSON_OBJECT);
|
||||
|
||||
create_object->set("object", note_object, JSON_OBJECT);
|
||||
U8* fetch_buffer = CAlloc(HTTP_FETCH_BUFFER_SIZE, adam_task);
|
||||
U8* fetch_buffer = CAlloc(HTTP_FETCH_BUFFER_SIZE, slon_mem_task);
|
||||
StrPrint(scratch_buffer, "%s/inbox", dest);
|
||||
@slon_activitypub_signed_request(scratch_buffer, fetch_buffer, create_object);
|
||||
Free(fetch_buffer);
|
||||
|
@ -532,7 +532,7 @@ U0 @slon_activitypub_async_delete_status_to(JsonObject* status, U8* dest)
|
|||
Sleep(1000);
|
||||
U8 scratch_buffer[2048];
|
||||
|
||||
U8* this_actor = StrNew(status->@("uri"), adam_task);
|
||||
U8* this_actor = StrNew(status->@("uri"), slon_mem_task);
|
||||
StrFind("/statuses/", this_actor)[0] = NULL;
|
||||
|
||||
JsonObject* delete_object = Json.CreateObject();
|
||||
|
@ -550,7 +550,7 @@ U0 @slon_activitypub_async_delete_status_to(JsonObject* status, U8* dest)
|
|||
ts_object->set("atomUri", status->@("uri"), JSON_STRING);
|
||||
|
||||
delete_object->set("object", ts_object, JSON_OBJECT);
|
||||
U8* fetch_buffer = CAlloc(HTTP_FETCH_BUFFER_SIZE, adam_task);
|
||||
U8* fetch_buffer = CAlloc(HTTP_FETCH_BUFFER_SIZE, slon_mem_task);
|
||||
StrPrint(scratch_buffer, "%s/inbox", dest);
|
||||
@slon_activitypub_signed_request(scratch_buffer, fetch_buffer, delete_object);
|
||||
Free(fetch_buffer);
|
||||
|
@ -561,7 +561,7 @@ U0 @slon_activitypub_async_follow(JsonObject* follow)
|
|||
{
|
||||
Sleep(1000);
|
||||
U8 scratch_buffer[1024];
|
||||
U8* fetch_buffer = CAlloc(HTTP_FETCH_BUFFER_SIZE, adam_task);
|
||||
U8* fetch_buffer = CAlloc(HTTP_FETCH_BUFFER_SIZE, slon_mem_task);
|
||||
StrPrint(scratch_buffer, "%s/inbox", follow->@("object"));
|
||||
@slon_activitypub_signed_request(scratch_buffer, fetch_buffer, follow);
|
||||
Free(fetch_buffer);
|
||||
|
@ -618,7 +618,7 @@ JsonObject* @slon_activitypub_get_account_for_remote_actor(SlonHttpSession* sess
|
|||
return NULL;
|
||||
}
|
||||
|
||||
U8* fetch_buffer = CAlloc(HTTP_FETCH_BUFFER_SIZE, adam_task);
|
||||
U8* fetch_buffer = CAlloc(HTTP_FETCH_BUFFER_SIZE, slon_mem_task);
|
||||
JsonObject* http_headers = Json.CreateObject();
|
||||
http_headers->set("accept", "application/json", JSON_STRING);
|
||||
@http_response* resp = Http.Get(url, fetch_buffer, NULL, http_headers);
|
||||
|
|
|
@ -146,7 +146,7 @@ U0 @slon_api_async_upload_to_catbox(SlonCatboxUpload* cb)
|
|||
|
||||
// build the multipart/form-data payload
|
||||
|
||||
U8* payload = CAlloc(4096 + data_size, adam_task);
|
||||
U8* payload = CAlloc(4096 + data_size, slon_mem_task);
|
||||
I64 payload_size = 0;
|
||||
|
||||
U8* boundary = "----------SlonFormBoundary00";
|
||||
|
@ -174,7 +174,7 @@ U0 @slon_api_async_upload_to_catbox(SlonCatboxUpload* cb)
|
|||
payload_size += StrLen(boundary);
|
||||
|
||||
// build the http headers
|
||||
U8* headers = CAlloc(4096, adam_task);
|
||||
U8* headers = CAlloc(4096, slon_mem_task);
|
||||
String.Append(headers, "POST /user/api.php HTTP/1.1\r\n");
|
||||
String.Append(headers, "Host: catbox.moe\r\n");
|
||||
String.Append(headers, "User-Agent: slon/1.0\r\n");
|
||||
|
@ -182,7 +182,7 @@ U0 @slon_api_async_upload_to_catbox(SlonCatboxUpload* cb)
|
|||
String.Append(headers, "Content-Type: multipart/form-data; boundary=%s\r\n\r\n", boundary);
|
||||
|
||||
I64 send_buffer_size = StrLen(headers) + payload_size;
|
||||
U8* send_buffer = CAlloc(send_buffer_size, adam_task);
|
||||
U8* send_buffer = CAlloc(send_buffer_size, slon_mem_task);
|
||||
|
||||
MemCpy(send_buffer, headers, StrLen(headers));
|
||||
MemCpy(send_buffer + StrLen(headers), payload, payload_size);
|
||||
|
@ -206,7 +206,7 @@ U0 @slon_api_async_upload_to_catbox(SlonCatboxUpload* cb)
|
|||
|
||||
I64 bytes_received = 0;
|
||||
I64 response_buffer_size = 0;
|
||||
U8* response_buffer = CAlloc(4096, adam_task);
|
||||
U8* response_buffer = CAlloc(4096, slon_mem_task);
|
||||
|
||||
while (!bytes_received) {
|
||||
bytes_received = s->receive(response_buffer + response_buffer_size, 4096);
|
||||
|
@ -222,7 +222,7 @@ U0 @slon_api_async_upload_to_catbox(SlonCatboxUpload* cb)
|
|||
url_ptr = StrFind("\r\n", url_ptr) + 2;
|
||||
StrFind("\r\n", url_ptr)[0] = NULL;
|
||||
|
||||
cb->key->value = StrNew(url_ptr, adam_task);
|
||||
cb->key->value = StrNew(url_ptr, slon_mem_task);
|
||||
cb->key->type = JSON_STRING;
|
||||
if (cb->callback) {
|
||||
cb->callback(cb->callback_arg);
|
||||
|
@ -248,7 +248,7 @@ U0 @slon_api_async_delete_from_catbox(U8* filename)
|
|||
|
||||
// build the multipart/form-data payload
|
||||
|
||||
U8* payload = CAlloc(4096, adam_task);
|
||||
U8* payload = CAlloc(4096, slon_mem_task);
|
||||
I64 payload_size = 0;
|
||||
|
||||
U8* boundary = "----------SlonFormBoundary00";
|
||||
|
@ -262,7 +262,7 @@ U0 @slon_api_async_delete_from_catbox(U8* filename)
|
|||
payload_size = StrLen(payload);
|
||||
|
||||
// build the http headers
|
||||
U8* headers = CAlloc(4096, adam_task);
|
||||
U8* headers = CAlloc(4096, slon_mem_task);
|
||||
String.Append(headers, "POST /user/api.php HTTP/1.1\r\n");
|
||||
String.Append(headers, "Host: catbox.moe\r\n");
|
||||
String.Append(headers, "User-Agent: slon/1.0\r\n");
|
||||
|
@ -270,7 +270,7 @@ U0 @slon_api_async_delete_from_catbox(U8* filename)
|
|||
String.Append(headers, "Content-Type: multipart/form-data; boundary=%s\r\n\r\n", boundary);
|
||||
|
||||
I64 send_buffer_size = StrLen(headers) + payload_size;
|
||||
U8* send_buffer = CAlloc(send_buffer_size, adam_task);
|
||||
U8* send_buffer = CAlloc(send_buffer_size, slon_mem_task);
|
||||
|
||||
MemCpy(send_buffer, headers, StrLen(headers));
|
||||
MemCpy(send_buffer + StrLen(headers), payload, payload_size);
|
||||
|
@ -283,7 +283,7 @@ U0 @slon_api_async_delete_from_catbox(U8* filename)
|
|||
|
||||
I64 bytes_received = 0;
|
||||
I64 response_buffer_size = 0;
|
||||
U8* response_buffer = CAlloc(4096, adam_task);
|
||||
U8* response_buffer = CAlloc(4096, slon_mem_task);
|
||||
|
||||
while (!bytes_received) {
|
||||
bytes_received = s->receive(response_buffer + response_buffer_size, 4096);
|
||||
|
|
|
@ -97,7 +97,7 @@ U64 @slon_calloc(SlonHttpSession* session, I64 size)
|
|||
{
|
||||
if (!session || !size)
|
||||
return NULL;
|
||||
U64 res = CAlloc(size, adam_task);
|
||||
U64 res = CAlloc(size, slon_mem_task);
|
||||
session->bytes_used += MSize2(res);
|
||||
// AdamLog("@slon_calloc: requested %d, total used: %d\n", MSize2(res), session->bytes_used);
|
||||
return res;
|
||||
|
@ -116,7 +116,7 @@ U64 @slon_malloc(SlonHttpSession* session, I64 size)
|
|||
{
|
||||
if (!session || !size)
|
||||
return NULL;
|
||||
U64 res = MAlloc(size, adam_task);
|
||||
U64 res = MAlloc(size, slon_mem_task);
|
||||
session->bytes_used += MSize2(res);
|
||||
// AdamLog("@slon_malloc: requested %d, total used: %d\n", MSize2(res), session->bytes_used);
|
||||
return res;
|
||||
|
@ -126,7 +126,7 @@ U8* @slon_strnew(SlonHttpSession* session, U8* str)
|
|||
{
|
||||
if (!session || !str)
|
||||
return NULL;
|
||||
U8* new = StrNew(str, adam_task);
|
||||
U8* new = StrNew(str, slon_mem_task);
|
||||
session->bytes_used += MSize2(new);
|
||||
// AdamLog("@slon_strnew: requested %d, total used: %d\n", MSize2(new), session->bytes_used);
|
||||
// AdamLog("@slon_strnew: %s\n", new);
|
||||
|
|
|
@ -26,7 +26,7 @@ U0 @slon_oauth_fetch_token(U8* client_id)
|
|||
return;
|
||||
}
|
||||
|
||||
U8* fetch_buffer = CAlloc(HTTP_FETCH_BUFFER_SIZE, adam_task);
|
||||
U8* fetch_buffer = CAlloc(HTTP_FETCH_BUFFER_SIZE, slon_mem_task);
|
||||
StrPrint(url_string, "%s%s", SLON_OAUTH_USERINFO_URL, access_token);
|
||||
@http_response* resp = fetch(url_string, fetch_buffer);
|
||||
|
||||
|
@ -49,7 +49,7 @@ oauth_free_and_return:
|
|||
|
||||
U0 @async_slon_oauth_fetch_token(U8* client_id)
|
||||
{
|
||||
Spawn(&@slon_oauth_fetch_token, StrNew(client_id, adam_task), "OauthFetchTokenTask");
|
||||
Spawn(&@slon_oauth_fetch_token, StrNew(client_id, slon_mem_task), "OauthFetchTokenTask");
|
||||
}
|
||||
|
||||
U8* @slon_oauth_generate_access_token(SlonHttpSession* session)
|
||||
|
|
|
@ -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,7 +60,7 @@ 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
|
||||
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;
|
||||
|
|
|
@ -138,7 +138,7 @@ I64 VirtioBlkInit()
|
|||
// Set up virt queue
|
||||
OutU16(virtio_blk.port + VIRTIO_PCI_QUEUE_SEL, 0);
|
||||
virtio_blk.vq_size = InU16(virtio_blk.port + VIRTIO_PCI_QUEUE_SIZE); // 256
|
||||
virtio_blk.vq = CAllocAligned(sizeof(@virtio_queue), 4096, adam_task->code_heap);
|
||||
virtio_blk.vq = CAllocAligned(sizeof(@virtio_queue), 4096, slon_mem_task->code_heap);
|
||||
OutU32(virtio_blk.port + VIRTIO_PCI_QUEUE_PFN, virtio_blk.vq / 4096);
|
||||
|
||||
// Init OK
|
||||
|
@ -152,7 +152,7 @@ U0 VIOFlush()
|
|||
{
|
||||
I64 j;
|
||||
I64 vq_idx;
|
||||
@virtio_blk_request* brq = CAlloc(sizeof(@virtio_blk_request), adam_task);
|
||||
@virtio_blk_request* brq = CAlloc(sizeof(@virtio_blk_request), slon_mem_task);
|
||||
brq->type = VIRTIO_BLK_T_FLUSH;
|
||||
brq->sector = NULL;
|
||||
vq_idx = virtio_blk.vq->available.index % 256;
|
||||
|
@ -181,7 +181,7 @@ Bool VIORBlks(CDrv* dv, U8* buf, I64 blk, I64 cnt)
|
|||
I64 i, j;
|
||||
I64 vq_idx;
|
||||
U64 addr;
|
||||
@virtio_blk_request* brq = CAlloc(sizeof(@virtio_blk_request), adam_task);
|
||||
@virtio_blk_request* brq = CAlloc(sizeof(@virtio_blk_request), slon_mem_task);
|
||||
for (i = 0; i < cnt; i++) {
|
||||
brq->type = VIRTIO_BLK_T_IN;
|
||||
brq->sector = blk + i;
|
||||
|
@ -218,7 +218,7 @@ Bool VIOWBlks(CDrv* dv, U8* buf, I64 blk, I64 cnt)
|
|||
I64 i, j;
|
||||
I64 vq_idx;
|
||||
U64 addr;
|
||||
@virtio_blk_request* brq = CAlloc(sizeof(@virtio_blk_request), adam_task);
|
||||
@virtio_blk_request* brq = CAlloc(sizeof(@virtio_blk_request), slon_mem_task);
|
||||
for (i = 0; i < cnt; i++) {
|
||||
brq->type = VIRTIO_BLK_T_OUT;
|
||||
brq->sector = blk + i;
|
||||
|
@ -277,7 +277,7 @@ U8 MountVirtioBlk()
|
|||
{ // Mount Virtio-blk device
|
||||
CDrv* dv = DrvMakeFreeSlot(DrvNextFreeLet('A'));
|
||||
CBlkDev* bd = BlkDevNextFreeSlot(dv->drv_let, BDT_RAM);
|
||||
CRedSeaBoot* bs = CAlloc(BLK_SIZE, adam_task);
|
||||
CRedSeaBoot* bs = CAlloc(BLK_SIZE, slon_mem_task);
|
||||
bd->max_blk = 512;
|
||||
BlkDevAdd(bd, , TRUE, TRUE);
|
||||
bd->type = BDT_VIRTIO_BLK;
|
||||
|
|
|
@ -244,7 +244,7 @@ U0 process_elf_rela_plt_entries(Elf* elf)
|
|||
for (i = 0; i < elf->rela_plt_size; i++) {
|
||||
symbol_exists = FALSE;
|
||||
entry_name = elf->dynstr + elf->dynsym[(rela_plt->r_info >> 32)].st_name;
|
||||
handler = MAlloc(sizeof(unimplemented_symbol), adam_task->code_heap);
|
||||
handler = MAlloc(sizeof(unimplemented_symbol), slon_mem_task->code_heap);
|
||||
MemCpy(handler, &unimplemented_symbol, sizeof(unimplemented_symbol));
|
||||
patch = handler + 0x0A;
|
||||
*patch = entry_name;
|
||||
|
|
|
@ -14,7 +14,7 @@ U0 calloc()
|
|||
{
|
||||
PUSH_SYSV_REGS
|
||||
GET_SYSV_ARGS
|
||||
CAlloc(p0 * p1, adam_task->code_heap);
|
||||
CAlloc(p0 * p1, slon_mem_task->code_heap);
|
||||
POP_SYSV_REGS
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ I64 @fwrite(U8* ptr, I64 size, I64 nmemb, U64 stream)
|
|||
switch (stream) {
|
||||
case stdout:
|
||||
case stderr:
|
||||
tmp = CAlloc((size * nmemb) + 1, adam_task->code_heap);
|
||||
tmp = CAlloc((size * nmemb) + 1, slon_mem_task->code_heap);
|
||||
MemCpy(tmp, ptr, (size * nmemb));
|
||||
#ifdef QEMU_RUN_TESTS
|
||||
QemuDebugMsg(tmp);
|
||||
|
@ -122,7 +122,7 @@ U0 malloc()
|
|||
{
|
||||
PUSH_SYSV_REGS
|
||||
GET_SYSV_ARGS
|
||||
MAlloc(p0, adam_task->code_heap);
|
||||
MAlloc(p0, slon_mem_task->code_heap);
|
||||
POP_SYSV_REGS
|
||||
}
|
||||
|
||||
|
@ -207,9 +207,9 @@ U8* @realloc(U8* ptr, I64 size)
|
|||
{
|
||||
U8* new;
|
||||
if (!ptr) {
|
||||
new = MAlloc(size, adam_task->code_heap);
|
||||
new = MAlloc(size, slon_mem_task->code_heap);
|
||||
} else {
|
||||
new = MAlloc(size, adam_task->code_heap);
|
||||
new = MAlloc(size, slon_mem_task->code_heap);
|
||||
MemCpy(new, ptr, size);
|
||||
Free(ptr);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ U0 _Znwm()
|
|||
// operator new(unsigned long)
|
||||
PUSH_SYSV_REGS
|
||||
GET_SYSV_ARGS
|
||||
MAlloc(p0, adam_task);
|
||||
MAlloc(p0, slon_mem_task);
|
||||
POP_SYSV_REGS
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,6 @@ U0 _ZnwmRKSt9nothrow_t()
|
|||
// operator new(unsigned long, std::nothrow_t const&)
|
||||
PUSH_SYSV_REGS
|
||||
GET_SYSV_ARGS
|
||||
MAlloc(p0, adam_task);
|
||||
MAlloc(p0, slon_mem_task);
|
||||
POP_SYSV_REGS
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ U0 _Z16os_device_callocj()
|
|||
// os_device_calloc(unsigned int)
|
||||
PUSH_SYSV_REGS
|
||||
GET_SYSV_ARGS
|
||||
CAllocAligned(p0, 4096, adam_task->code_heap);
|
||||
CAllocAligned(p0, 4096, slon_mem_task->code_heap);
|
||||
POP_SYSV_REGS
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ U0 _Z7os_exitv()
|
|||
|
||||
U8* @os_file_picker(U8* path, U8* glob)
|
||||
{
|
||||
U8* full_path = CAlloc(StrLen(path) + StrLen(glob) + 4, adam_task);
|
||||
U8* full_path = CAlloc(StrLen(path) + StrLen(glob) + 4, slon_mem_task);
|
||||
CatPrint(full_path, "%s/%s", path, glob);
|
||||
|
||||
CDirEntry* de = FilesFind(full_path);
|
||||
|
@ -72,7 +72,7 @@ U8* @os_file_picker(U8* path, U8* glob)
|
|||
tmpde = tmpde->next;
|
||||
}
|
||||
|
||||
file_list = CAlloc(list_size, adam_task);
|
||||
file_list = CAlloc(list_size, slon_mem_task);
|
||||
|
||||
tmpde = de;
|
||||
while (tmpde) {
|
||||
|
@ -87,13 +87,13 @@ U8* @os_file_picker(U8* path, U8* glob)
|
|||
|
||||
if (list_index < 0) {
|
||||
DirTreeDel(de);
|
||||
return StrNew("", adam_task);
|
||||
return StrNew("", slon_mem_task);
|
||||
}
|
||||
|
||||
tmpde = de;
|
||||
while (tmpde) {
|
||||
if (list_index == list_pos) {
|
||||
selected_file = CAlloc(StrLen(path) + StrLen(tmpde->name) + 4, adam_task);
|
||||
selected_file = CAlloc(StrLen(path) + StrLen(tmpde->name) + 4, slon_mem_task);
|
||||
CatPrint(selected_file, "%s/%s", path, tmpde->name);
|
||||
break;
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ U0 _Z14os_file_pickerPKcS0_()
|
|||
|
||||
U8* @os_files_list(U8* path)
|
||||
{
|
||||
U8* full_path = CAlloc(StrLen(path) + 4, adam_task);
|
||||
U8* full_path = CAlloc(StrLen(path) + 4, slon_mem_task);
|
||||
CatPrint(full_path, "%s", path);
|
||||
|
||||
CDirEntry* de = FilesFind(full_path);
|
||||
|
@ -138,7 +138,7 @@ U8* @os_files_list(U8* path)
|
|||
if (!list_size)
|
||||
return NULL;
|
||||
|
||||
file_list = CAlloc(list_size, adam_task);
|
||||
file_list = CAlloc(list_size, slon_mem_task);
|
||||
|
||||
tmpde = de;
|
||||
I64 counter = 0;
|
||||
|
@ -243,7 +243,7 @@ U0 _Z19os_read_entire_filePKcPl()
|
|||
|
||||
U0 @os_screenshot()
|
||||
{
|
||||
CDC* dc = DCScrnCapture(, adam_task);
|
||||
CDC* dc = DCScrnCapture(, slon_mem_task);
|
||||
Image.Write("B:/screenshot.png", dc);
|
||||
DCDel(dc);
|
||||
}
|
||||
|
@ -263,7 +263,7 @@ U8* @os_to_uppercase(U8* instr)
|
|||
return NULL;
|
||||
if (!StrLen(instr))
|
||||
return NULL;
|
||||
U8* outstr = CAlloc(StrLen(instr) + 1, adam_task);
|
||||
U8* outstr = CAlloc(StrLen(instr) + 1, slon_mem_task);
|
||||
I64 i;
|
||||
for (i = 0; i < StrLen(instr); i++)
|
||||
outstr[i] = ToUpper(instr[i]);
|
||||
|
|
|
@ -18,7 +18,7 @@ U8* @base64_decode(U8* input, I64* output_length)
|
|||
}
|
||||
|
||||
// Allocate memory for the decoded data
|
||||
U8* decoded_data = CAlloc(*output_length, adam_task);
|
||||
U8* decoded_data = CAlloc(*output_length, slon_mem_task);
|
||||
if (decoded_data == NULL) {
|
||||
return NULL; // Memory allocation failed
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ U8* @base64_encode(U8* input, I64 input_length)
|
|||
I64 i;
|
||||
U8 buf[3];
|
||||
I64 c = 0;
|
||||
U8* output = CAlloc(input_length * 2, adam_task);
|
||||
U8* output = CAlloc(input_length * 2, slon_mem_task);
|
||||
|
||||
for (i = 0; i < input_length; i += 3) {
|
||||
buf[0] = input[i];
|
||||
|
|
|
@ -78,7 +78,7 @@ U8* @http_string_from_fifo(CFifoU8* f)
|
|||
{
|
||||
U8 ch;
|
||||
I64 i = 0;
|
||||
U8* str = CAlloc(FifoU8Cnt(f) + 1, adam_task);
|
||||
U8* str = CAlloc(FifoU8Cnt(f) + 1, slon_mem_task);
|
||||
while (FifoU8Cnt(f)) {
|
||||
FifoU8Rem(f, &ch);
|
||||
str[i] = ch;
|
||||
|
@ -121,22 +121,22 @@ U0 @http_free_response(@http_response* resp)
|
|||
U8 hex[3];
|
||||
I64 i = 0;
|
||||
I64 state = HTTP_PARSE_SCHEME;
|
||||
CFifoU8* consume_fifo = FifoU8New(HTTP_PARSE_URL_FIFO_SIZE, adam_task);
|
||||
@http_url* url = CAlloc(sizeof(@http_url), adam_task);
|
||||
CFifoU8* consume_fifo = FifoU8New(HTTP_PARSE_URL_FIFO_SIZE, slon_mem_task);
|
||||
@http_url* url = CAlloc(sizeof(@http_url), slon_mem_task);
|
||||
while (1) {
|
||||
switch (str[i]) {
|
||||
case 0:
|
||||
switch (state) {
|
||||
case HTTP_PARSE_HOST:
|
||||
url->host = @http_string_from_fifo(consume_fifo);
|
||||
url->path = StrNew("/", adam_task);
|
||||
url->path = StrNew("/", slon_mem_task);
|
||||
goto done_parsing_url;
|
||||
break;
|
||||
case HTTP_PARSE_PORT:
|
||||
buf = @http_string_from_fifo(consume_fifo);
|
||||
url->port = Str2I64(buf);
|
||||
Free(buf);
|
||||
url->path = StrNew("/", adam_task);
|
||||
url->path = StrNew("/", slon_mem_task);
|
||||
goto done_parsing_url;
|
||||
break;
|
||||
case HTTP_PARSE_PATH:
|
||||
|
@ -297,9 +297,9 @@ U0 @http_parse_response_headers(@http_response* resp, U8* buffer, I64 length)
|
|||
(*StrFind(" ", resp_protocol)) = NULL;
|
||||
(*StrFind(" ", resp_status_code)) = NULL;
|
||||
|
||||
resp->status.protocol = StrNew(resp_protocol, adam_task);
|
||||
resp->status.protocol = StrNew(resp_protocol, slon_mem_task);
|
||||
resp->status.code = Str2I64(resp_status_code);
|
||||
resp->status.text = StrNew(resp_text, adam_task);
|
||||
resp->status.text = StrNew(resp_text, slon_mem_task);
|
||||
|
||||
for (i = 1; i < lines_count; i++) {
|
||||
for (j = 0; j < StrLen(lines[i]); j++) {
|
||||
|
@ -308,7 +308,7 @@ U0 @http_parse_response_headers(@http_response* resp, U8* buffer, I64 length)
|
|||
key_ptr = lines[i];
|
||||
value_ptr = lines[i] + j + 2;
|
||||
(*StrFind("\r", value_ptr)) = NULL;
|
||||
Json.Set(headers, key_ptr, StrNew(value_ptr, adam_task), JSON_STRING);
|
||||
Json.Set(headers, key_ptr, StrNew(value_ptr, slon_mem_task), JSON_STRING);
|
||||
goto @http_next_header_line;
|
||||
}
|
||||
}
|
||||
|
@ -350,9 +350,9 @@ I64 @http_req(@http_request* req)
|
|||
I64 cnt = 1;
|
||||
I64 len = NULL;
|
||||
|
||||
buf = CAlloc(HTTP_MIN_REQUEST_BUFFER_SIZE, adam_task);
|
||||
buf = CAlloc(HTTP_MIN_REQUEST_BUFFER_SIZE, slon_mem_task);
|
||||
if (req->headers) {
|
||||
headers_buf = CAlloc(HTTP_MIN_REQUEST_BUFFER_SIZE, adam_task);
|
||||
headers_buf = CAlloc(HTTP_MIN_REQUEST_BUFFER_SIZE, slon_mem_task);
|
||||
JsonKey* key = req->headers->keys;
|
||||
while (key) {
|
||||
StrPrint(headers_buf + StrLen(headers_buf), "%s: %s\r\n", key->name, key->value);
|
||||
|
@ -467,8 +467,8 @@ Bool @http_scheme_is_https(@http_url* url)
|
|||
|
||||
@http_response* @http_get(@http_url* url, U8* buf, U64 return_req = NULL, JsonObject* headers = NULL)
|
||||
{
|
||||
@http_response* resp = CAlloc(sizeof(@http_response), adam_task);
|
||||
@http_request* req = CAlloc(sizeof(@http_request), adam_task);
|
||||
@http_response* resp = CAlloc(sizeof(@http_response), slon_mem_task);
|
||||
@http_request* req = CAlloc(sizeof(@http_request), slon_mem_task);
|
||||
if (return_req)
|
||||
MemCpy(return_req, &req, sizeof(U64));
|
||||
req->url = url;
|
||||
|
@ -482,8 +482,8 @@ Bool @http_scheme_is_https(@http_url* url)
|
|||
|
||||
@http_response* @http_head(@http_url* url, U8* buf, JsonObject* headers = NULL)
|
||||
{
|
||||
@http_response* resp = CAlloc(sizeof(@http_response), adam_task);
|
||||
@http_request* req = CAlloc(sizeof(@http_request), adam_task);
|
||||
@http_response* resp = CAlloc(sizeof(@http_response), slon_mem_task);
|
||||
@http_request* req = CAlloc(sizeof(@http_request), slon_mem_task);
|
||||
req->url = url;
|
||||
req->buf = buf;
|
||||
req->type = HTTP_REQ_HEAD;
|
||||
|
@ -495,8 +495,8 @@ Bool @http_scheme_is_https(@http_url* url)
|
|||
|
||||
@http_response* @http_post(@http_url* url, U8* buf, U8* data, JsonObject* headers = NULL)
|
||||
{
|
||||
@http_response* resp = CAlloc(sizeof(@http_response), adam_task);
|
||||
@http_request* req = CAlloc(sizeof(@http_request), adam_task);
|
||||
@http_response* resp = CAlloc(sizeof(@http_response), slon_mem_task);
|
||||
@http_request* req = CAlloc(sizeof(@http_request), slon_mem_task);
|
||||
req->url = url;
|
||||
req->buf = buf;
|
||||
req->type = HTTP_REQ_POST;
|
||||
|
@ -509,8 +509,8 @@ Bool @http_scheme_is_https(@http_url* url)
|
|||
|
||||
@http_response* @http_put(@http_url* url, U8* buf, U8* data, JsonObject* headers = NULL)
|
||||
{
|
||||
@http_response* resp = CAlloc(sizeof(@http_response), adam_task);
|
||||
@http_request* req = CAlloc(sizeof(@http_request), adam_task);
|
||||
@http_response* resp = CAlloc(sizeof(@http_response), slon_mem_task);
|
||||
@http_request* req = CAlloc(sizeof(@http_request), slon_mem_task);
|
||||
req->url = url;
|
||||
req->buf = buf;
|
||||
req->type = HTTP_REQ_PUT;
|
||||
|
@ -558,7 +558,7 @@ U0 @http_cache_resource(U8* src, U8* data, I64 size, U8* cache_directory = HTTP_
|
|||
|
||||
U8* @http_get_cached_resource_filename(U8* src, U8* cache_directory = HTTP_CACHE_DIRECTORY)
|
||||
{
|
||||
U8* buf = CAlloc(512, adam_task);
|
||||
U8* buf = CAlloc(512, slon_mem_task);
|
||||
U8* src_md5 = md5_string(src, StrLen(src));
|
||||
StrCpy(buf, cache_directory);
|
||||
StrPrint(buf + StrLen(buf), "/%s", src_md5);
|
||||
|
@ -591,7 +591,7 @@ I64 curl(U8* url_string)
|
|||
{
|
||||
if (!url_string)
|
||||
return 0;
|
||||
U8* fetch_buffer = CAlloc(HTTP_FETCH_BUFFER_SIZE, adam_task);
|
||||
U8* fetch_buffer = CAlloc(HTTP_FETCH_BUFFER_SIZE, slon_mem_task);
|
||||
@http_response* resp = fetch(url_string, fetch_buffer);
|
||||
if (!resp)
|
||||
return 0;
|
||||
|
@ -614,7 +614,7 @@ I64 download(U8* path, U8* url_string)
|
|||
{
|
||||
if (!path || !url_string)
|
||||
return 0;
|
||||
U8* fetch_buffer = CAlloc(HTTP_FETCH_BUFFER_SIZE, adam_task);
|
||||
U8* fetch_buffer = CAlloc(HTTP_FETCH_BUFFER_SIZE, slon_mem_task);
|
||||
@http_response* resp = fetch(url_string, fetch_buffer);
|
||||
if (!resp)
|
||||
return 0;
|
||||
|
|
|
@ -181,7 +181,7 @@ U8* @json_string_from_fifo(CFifoU8* f)
|
|||
{
|
||||
U8 ch;
|
||||
I64 i = 0;
|
||||
U8* str = CAlloc(FifoU8Cnt(f) + 1, adam_task);
|
||||
U8* str = CAlloc(FifoU8Cnt(f) + 1, slon_mem_task);
|
||||
while (FifoU8Cnt(f)) {
|
||||
FifoU8Rem(f, &ch);
|
||||
str[i] = ch;
|
||||
|
@ -413,7 +413,7 @@ U0 @json_parse_object(@json_parser* parser, @json_object* obj)
|
|||
parser->state = JSON_STATE_OBJECT_SEPARATOR;
|
||||
break;
|
||||
case JSON_STATE_OBJECT:
|
||||
key = CAlloc(sizeof(@json_key), adam_task);
|
||||
key = CAlloc(sizeof(@json_key), slon_mem_task);
|
||||
key->sig = JSON_SIG;
|
||||
parser->state = JSON_STATE_OBJECT_KEY;
|
||||
break;
|
||||
|
@ -498,7 +498,7 @@ U0 @json_parse_array(@json_parser* parser, @json_array* arr)
|
|||
return;
|
||||
break;
|
||||
}
|
||||
item = CAlloc(sizeof(@json_item), adam_task);
|
||||
item = CAlloc(sizeof(@json_item), slon_mem_task);
|
||||
item->sig = JSON_SIG;
|
||||
parser->state = JSON_STATE_ARRAY_TYPE;
|
||||
}
|
||||
|
@ -707,7 +707,7 @@ extern @json_callable_object* @json_create_callable_object(@json_object* obj);
|
|||
|
||||
@json_element* @json_parse_object_or_array(@json_parser* parser)
|
||||
{
|
||||
@json_element* el = CAlloc(sizeof(@json_element) * 2, adam_task);
|
||||
@json_element* el = CAlloc(sizeof(@json_element) * 2, slon_mem_task);
|
||||
el->sig = JSON_SIG;
|
||||
while (1) {
|
||||
switch (parser->stream[parser->pos]) {
|
||||
|
@ -747,8 +747,8 @@ extern @json_callable_object* @json_create_callable_object(@json_object* obj);
|
|||
|
||||
@json_element* @json_parse(U8* str)
|
||||
{
|
||||
@json_parser* parser = CAlloc(sizeof(@json_parser), adam_task);
|
||||
parser->consumed = FifoU8New(JSON_PARSER_FIFO_SIZE, adam_task);
|
||||
@json_parser* parser = CAlloc(sizeof(@json_parser), slon_mem_task);
|
||||
parser->consumed = FifoU8New(JSON_PARSER_FIFO_SIZE, slon_mem_task);
|
||||
// parser->debug = TRUE;
|
||||
parser->stream = str;
|
||||
@json_element* root = @json_parse_object_or_array(parser);
|
||||
|
@ -1006,9 +1006,9 @@ U0 @json_stringify_object_or_array(@json_stringify_string* str, @json_element* e
|
|||
|
||||
U8* @json_stringify(@json_element* el, I64 buf_size = JSON_STRINGIFY_BUF_SIZE)
|
||||
{
|
||||
// U8* str = CAlloc(buf_size, adam_task);
|
||||
@json_stringify_string* str = CAlloc(sizeof(@json_stringify_string), adam_task);
|
||||
U8* value = CAlloc(buf_size, adam_task);
|
||||
// U8* str = CAlloc(buf_size, slon_mem_task);
|
||||
@json_stringify_string* str = CAlloc(sizeof(@json_stringify_string), slon_mem_task);
|
||||
U8* value = CAlloc(buf_size, slon_mem_task);
|
||||
str->value = value;
|
||||
@json_stringify_object_or_array(str, el);
|
||||
Free(str);
|
||||
|
@ -1049,12 +1049,12 @@ U0 @json_set(@json_object* obj, U8* key, U64 value, I64 type = JSON_SAME)
|
|||
}
|
||||
iter_key = iter_key->next;
|
||||
}
|
||||
@json_key* new_key = CAlloc(sizeof(@json_key), adam_task);
|
||||
@json_key* new_key = CAlloc(sizeof(@json_key), slon_mem_task);
|
||||
new_key->sig = JSON_SIG;
|
||||
new_key->name = StrNew(key, adam_task);
|
||||
new_key->name = StrNew(key, slon_mem_task);
|
||||
new_key->type = type;
|
||||
if (new_key->type == JSON_STRING)
|
||||
new_key->value = StrNew(value, adam_task);
|
||||
new_key->value = StrNew(value, slon_mem_task);
|
||||
else
|
||||
new_key->value = value;
|
||||
@json_insert_key(obj, new_key);
|
||||
|
@ -1102,14 +1102,14 @@ U0 @json_callable_object_unset_wrapper_function(U8* key)
|
|||
@json_callable_object* @json_create_callable_object(@json_object* obj)
|
||||
{
|
||||
// Alloc callable object and copy instance
|
||||
@json_callable_object* cobj = CAlloc(sizeof(@json_callable_object), adam_task);
|
||||
@json_callable_object* cobj = CAlloc(sizeof(@json_callable_object), slon_mem_task);
|
||||
cobj->sig = JSON_SIG;
|
||||
MemCpy(cobj, obj, sizeof(@json_object));
|
||||
|
||||
// Create a copy of function and patch Get
|
||||
U64 a;
|
||||
I64 code_size = MSize(&@json_callable_object_get_wrapper_function);
|
||||
cobj->@ = CAlloc(code_size, adam_task->code_heap);
|
||||
cobj->@ = CAlloc(code_size, slon_mem_task->code_heap);
|
||||
MemCpy(cobj->@, &@json_callable_object_get_wrapper_function, code_size);
|
||||
|
||||
a = cobj->@;
|
||||
|
@ -1122,7 +1122,7 @@ U0 @json_callable_object_unset_wrapper_function(U8* key)
|
|||
|
||||
// Create a copy of function and patch Set
|
||||
code_size = MSize(&@json_callable_object_set_wrapper_function);
|
||||
cobj->set = CAlloc(code_size, adam_task->code_heap);
|
||||
cobj->set = CAlloc(code_size, slon_mem_task->code_heap);
|
||||
MemCpy(cobj->set, &@json_callable_object_set_wrapper_function, code_size);
|
||||
|
||||
a = cobj->set;
|
||||
|
@ -1135,7 +1135,7 @@ U0 @json_callable_object_unset_wrapper_function(U8* key)
|
|||
|
||||
// Create a copy of function and patch Unset
|
||||
code_size = MSize(&@json_callable_object_unset_wrapper_function);
|
||||
cobj->unset = CAlloc(code_size, adam_task->code_heap);
|
||||
cobj->unset = CAlloc(code_size, slon_mem_task->code_heap);
|
||||
MemCpy(cobj->unset, &@json_callable_object_unset_wrapper_function, code_size);
|
||||
|
||||
a = cobj->unset;
|
||||
|
@ -1154,7 +1154,7 @@ U0 @json_callable_object_unset_wrapper_function(U8* key)
|
|||
|
||||
@json_callable_object* @json_create_object()
|
||||
{
|
||||
@json_object* obj = CAlloc(sizeof(@json_object), adam_task);
|
||||
@json_object* obj = CAlloc(sizeof(@json_object), slon_mem_task);
|
||||
obj->sig = JSON_SIG;
|
||||
obj->type = JSON_OBJECT;
|
||||
return @json_create_callable_object(obj);
|
||||
|
@ -1162,11 +1162,11 @@ U0 @json_callable_object_unset_wrapper_function(U8* key)
|
|||
|
||||
@json_item* @json_create_item(U64 value, I64 type)
|
||||
{
|
||||
@json_item* item = CAlloc(sizeof(@json_item), adam_task);
|
||||
@json_item* item = CAlloc(sizeof(@json_item), slon_mem_task);
|
||||
item->sig = JSON_SIG;
|
||||
item->type = type;
|
||||
if (item->type == JSON_STRING)
|
||||
item->value = StrNew(value, adam_task);
|
||||
item->value = StrNew(value, slon_mem_task);
|
||||
else
|
||||
item->value = value;
|
||||
return item;
|
||||
|
@ -1259,14 +1259,14 @@ U0 @json_callable_array_remove_wrapper_function(I64 index)
|
|||
@json_callable_array* @json_create_callable_array(@json_array* arr)
|
||||
{
|
||||
// Alloc callable object and copy instance
|
||||
@json_callable_array* carr = CAlloc(sizeof(@json_callable_array), adam_task);
|
||||
@json_callable_array* carr = CAlloc(sizeof(@json_callable_array), slon_mem_task);
|
||||
carr->sig = JSON_SIG;
|
||||
MemCpy(carr, arr, sizeof(@json_array));
|
||||
|
||||
// Create a copy of function and patch Index
|
||||
U64 a;
|
||||
I64 code_size = MSize(&@json_callable_array_index_wrapper_function);
|
||||
carr->@ = CAlloc(code_size, adam_task->code_heap);
|
||||
carr->@ = CAlloc(code_size, slon_mem_task->code_heap);
|
||||
MemCpy(carr->@, &@json_callable_array_index_wrapper_function, code_size);
|
||||
|
||||
a = carr->@;
|
||||
|
@ -1282,7 +1282,7 @@ U0 @json_callable_array_remove_wrapper_function(I64 index)
|
|||
|
||||
// Create a copy of function and patch Append
|
||||
code_size = MSize(&@json_callable_array_append_wrapper_function);
|
||||
carr->append = CAlloc(code_size, adam_task->code_heap);
|
||||
carr->append = CAlloc(code_size, slon_mem_task->code_heap);
|
||||
MemCpy(carr->append, &@json_callable_array_append_wrapper_function, code_size);
|
||||
|
||||
a = carr->append;
|
||||
|
@ -1295,7 +1295,7 @@ U0 @json_callable_array_remove_wrapper_function(I64 index)
|
|||
|
||||
// Create a copy of function and patch Prepend
|
||||
code_size = MSize(&@json_callable_array_prepend_wrapper_function);
|
||||
carr->prepend = CAlloc(code_size, adam_task->code_heap);
|
||||
carr->prepend = CAlloc(code_size, slon_mem_task->code_heap);
|
||||
MemCpy(carr->prepend, &@json_callable_array_prepend_wrapper_function, code_size);
|
||||
|
||||
a = carr->prepend;
|
||||
|
@ -1308,7 +1308,7 @@ U0 @json_callable_array_remove_wrapper_function(I64 index)
|
|||
|
||||
// Create a copy of function and patch Insert
|
||||
code_size = MSize(&@json_callable_array_insert_wrapper_function);
|
||||
carr->insert = CAlloc(code_size, adam_task->code_heap);
|
||||
carr->insert = CAlloc(code_size, slon_mem_task->code_heap);
|
||||
MemCpy(carr->insert, &@json_callable_array_insert_wrapper_function, code_size);
|
||||
|
||||
a = carr->insert;
|
||||
|
@ -1321,7 +1321,7 @@ U0 @json_callable_array_remove_wrapper_function(I64 index)
|
|||
|
||||
// Create a copy of function and patch Remove
|
||||
code_size = MSize(&@json_callable_array_remove_wrapper_function);
|
||||
carr->remove = CAlloc(code_size, adam_task->code_heap);
|
||||
carr->remove = CAlloc(code_size, slon_mem_task->code_heap);
|
||||
MemCpy(carr->remove, &@json_callable_array_remove_wrapper_function, code_size);
|
||||
|
||||
a = carr->remove;
|
||||
|
@ -1337,7 +1337,7 @@ U0 @json_callable_array_remove_wrapper_function(I64 index)
|
|||
|
||||
@json_array* @json_create_array()
|
||||
{
|
||||
@json_array* arr = CAlloc(sizeof(@json_array), adam_task);
|
||||
@json_array* arr = CAlloc(sizeof(@json_array), slon_mem_task);
|
||||
arr->sig = JSON_SIG;
|
||||
arr->type = JSON_ARRAY;
|
||||
return @json_create_callable_array(arr);
|
||||
|
|
|
@ -8,7 +8,7 @@ U0 @string_append(U8* dst, U8* fmt, ...)
|
|||
if (argc) {
|
||||
buf = StrPrintJoin(NULL, fmt, argc, argv);
|
||||
} else {
|
||||
buf = StrNew(fmt, adam_task);
|
||||
buf = StrNew(fmt, slon_mem_task);
|
||||
}
|
||||
U8* src = buf;
|
||||
StrCpy(dst + StrLen(dst), src);
|
||||
|
@ -53,7 +53,7 @@ Bool @string_ends_with(U8* fragment, U8* str)
|
|||
U8* @string_replace(U8* s, U8* oldW, U8* newW)
|
||||
{
|
||||
if (!StrFind(oldW, s)) {
|
||||
return StrNew(s, adam_task);
|
||||
return StrNew(s, slon_mem_task);
|
||||
}
|
||||
U8* result;
|
||||
I64 i, cnt = 0;
|
||||
|
@ -66,7 +66,7 @@ U8* @string_replace(U8* s, U8* oldW, U8* newW)
|
|||
i += oldWlen - 1;
|
||||
}
|
||||
}
|
||||
result = MAlloc(i + cnt * (newWlen - oldWlen) + 1, adam_task);
|
||||
result = MAlloc(i + cnt * (newWlen - oldWlen) + 1, slon_mem_task);
|
||||
i = 0;
|
||||
while (*s) {
|
||||
if (StrFind(oldW, s) == s) {
|
||||
|
@ -85,7 +85,7 @@ U8** @string_split(U8* s, U8 ch = '\n', I64* cnt)
|
|||
U8 check_buf[4];
|
||||
StrPrint(check_buf, "%c", ch);
|
||||
if (!StrFind(check_buf, s)) {
|
||||
U8** same_arr = CAlloc(sizeof(U8*) * 1, adam_task);
|
||||
U8** same_arr = CAlloc(sizeof(U8*) * 1, slon_mem_task);
|
||||
same_arr[0] = s;
|
||||
*cnt = 1;
|
||||
return same_arr;
|
||||
|
@ -101,7 +101,7 @@ U8** @string_split(U8* s, U8 ch = '\n', I64* cnt)
|
|||
return NULL;
|
||||
cnt[0]++;
|
||||
I64 i = -1;
|
||||
U8** arr = CAlloc(sizeof(U8*) * cnt[0], adam_task);
|
||||
U8** arr = CAlloc(sizeof(U8*) * cnt[0], slon_mem_task);
|
||||
p = s;
|
||||
while (*p) {
|
||||
if (*p == ch || i < 0) {
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
/* clang-format off */
|
||||
|
||||
U0 @slon_mem_task_loop()
|
||||
{
|
||||
while(1){Sleep(1);};
|
||||
}
|
||||
|
||||
CTask* slon_mem_task = Spawn(&@slon_mem_task_loop,, "SlonMemTask");
|
||||
|
||||
DocMax(adam_task);
|
||||
WinMax(adam_task);
|
||||
WinToTop(adam_task);
|
||||
|
|
|
@ -288,7 +288,7 @@ U32* @image_get_rgba_buffer_from_dc_body(CDC* dc)
|
|||
{
|
||||
if (!dc)
|
||||
return NULL;
|
||||
U32* pixels = CAlloc((dc->width * dc->height) * 4, adam_task);
|
||||
U32* pixels = CAlloc((dc->width * dc->height) * 4, slon_mem_task);
|
||||
I64 x;
|
||||
I64 y;
|
||||
I64 p = 0;
|
||||
|
@ -368,12 +368,12 @@ CDC* @image_from_buffer(U8* buffer, I64 len)
|
|||
PopUpOk(@stbi_failure_reason);
|
||||
if (!z)
|
||||
return NULL; // no frames?
|
||||
@image_collection* collection = CAlloc(sizeof(@image_collection), adam_task);
|
||||
@image_collection* collection = CAlloc(sizeof(@image_collection), slon_mem_task);
|
||||
@image_frame* frame;
|
||||
collection->frames = CAlloc(sizeof(@image_frame*) * z, adam_task);
|
||||
collection->frames = CAlloc(sizeof(@image_frame*) * z, slon_mem_task);
|
||||
collection->count = z;
|
||||
for (i = 0; i < z; i++) {
|
||||
frame = CAlloc(sizeof(@image_frame), adam_task);
|
||||
frame = CAlloc(sizeof(@image_frame), slon_mem_task);
|
||||
frame->dc = @image_generate_dc_from_pixels(pixels, x, y);
|
||||
frame->sprite = DC2Sprite(frame->dc);
|
||||
frame->delay = delays[i];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue