core: Prefer JS_AtomToCString() over JS_AtomToString() + JS_ToCString().
Some checks failed
Build Tilde Friends / Build-All (push) Has been cancelled
Some checks failed
Build Tilde Friends / Build-All (push) Has been cancelled
This commit is contained in:
@ -75,7 +75,6 @@ static int _object_to_headers(JSContext* context, JSValue object, const char** h
|
|||||||
JS_GetOwnPropertyNames(context, &ptab, &plen, object, JS_GPN_STRING_MASK);
|
JS_GetOwnPropertyNames(context, &ptab, &plen, object, JS_GPN_STRING_MASK);
|
||||||
for (; count < (int)plen && count < headers_length / 2; ++count)
|
for (; count < (int)plen && count < headers_length / 2; ++count)
|
||||||
{
|
{
|
||||||
JSValue key = JS_AtomToString(context, ptab[count].atom);
|
|
||||||
JSPropertyDescriptor desc;
|
JSPropertyDescriptor desc;
|
||||||
JSValue key_value = JS_NULL;
|
JSValue key_value = JS_NULL;
|
||||||
if (JS_GetOwnProperty(context, &desc, object, ptab[count].atom) == 1)
|
if (JS_GetOwnProperty(context, &desc, object, ptab[count].atom) == 1)
|
||||||
@ -84,9 +83,8 @@ static int _object_to_headers(JSContext* context, JSValue object, const char** h
|
|||||||
JS_FreeValue(context, desc.setter);
|
JS_FreeValue(context, desc.setter);
|
||||||
JS_FreeValue(context, desc.getter);
|
JS_FreeValue(context, desc.getter);
|
||||||
}
|
}
|
||||||
headers[count * 2 + 0] = JS_ToCString(context, key);
|
headers[count * 2 + 0] = JS_AtomToCString(context, ptab[count].atom);
|
||||||
headers[count * 2 + 1] = JS_ToCString(context, key_value);
|
headers[count * 2 + 1] = JS_ToCString(context, key_value);
|
||||||
JS_FreeValue(context, key);
|
|
||||||
JS_FreeValue(context, key_value);
|
JS_FreeValue(context, key_value);
|
||||||
}
|
}
|
||||||
for (uint32_t i = 0; i < plen; ++i)
|
for (uint32_t i = 0; i < plen; ++i)
|
||||||
|
@ -127,8 +127,7 @@ void tf_ssb_ebt_receive_clock(tf_ssb_ebt_t* ebt, JSContext* context, JSValue clo
|
|||||||
}
|
}
|
||||||
if (!JS_IsUndefined(in_clock))
|
if (!JS_IsUndefined(in_clock))
|
||||||
{
|
{
|
||||||
JSValue key = JS_AtomToString(context, ptab[i].atom);
|
const char* author = JS_AtomToCString(context, ptab[i].atom);
|
||||||
const char* author = JS_ToCString(context, key);
|
|
||||||
int64_t sequence = -1;
|
int64_t sequence = -1;
|
||||||
JS_ToInt64(context, &sequence, in_clock);
|
JS_ToInt64(context, &sequence, in_clock);
|
||||||
|
|
||||||
@ -153,7 +152,6 @@ void tf_ssb_ebt_receive_clock(tf_ssb_ebt_t* ebt, JSContext* context, JSValue clo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
JS_FreeCString(context, author);
|
JS_FreeCString(context, author);
|
||||||
JS_FreeValue(context, key);
|
|
||||||
}
|
}
|
||||||
JS_FreeValue(context, in_clock);
|
JS_FreeValue(context, in_clock);
|
||||||
}
|
}
|
||||||
|
@ -142,8 +142,7 @@ void tf_ssb_export(tf_ssb_t* ssb, const char* key)
|
|||||||
JSPropertyDescriptor desc;
|
JSPropertyDescriptor desc;
|
||||||
if (JS_GetOwnProperty(context, &desc, files, ptab[i].atom) == 1)
|
if (JS_GetOwnProperty(context, &desc, files, ptab[i].atom) == 1)
|
||||||
{
|
{
|
||||||
JSValue key = JS_AtomToString(context, ptab[i].atom);
|
const char* file_name = JS_AtomToCString(context, ptab[i].atom);
|
||||||
const char* file_name = JS_ToCString(context, key);
|
|
||||||
const char* blob_id = JS_ToCString(context, desc.value);
|
const char* blob_id = JS_ToCString(context, desc.value);
|
||||||
|
|
||||||
uint8_t* file_blob = NULL;
|
uint8_t* file_blob = NULL;
|
||||||
@ -156,7 +155,6 @@ void tf_ssb_export(tf_ssb_t* ssb, const char* key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
JS_FreeCString(context, file_name);
|
JS_FreeCString(context, file_name);
|
||||||
JS_FreeValue(context, key);
|
|
||||||
JS_FreeCString(context, blob_id);
|
JS_FreeCString(context, blob_id);
|
||||||
JS_FreeValue(context, desc.value);
|
JS_FreeValue(context, desc.value);
|
||||||
JS_FreeValue(context, desc.setter);
|
JS_FreeValue(context, desc.setter);
|
||||||
|
@ -716,7 +716,7 @@ static void _tf_ssb_rpc_connection_blobs_createWants_callback(
|
|||||||
{
|
{
|
||||||
for (uint32_t i = 0; i < plen; ++i)
|
for (uint32_t i = 0; i < plen; ++i)
|
||||||
{
|
{
|
||||||
JSValue key = JS_AtomToString(context, ptab[i].atom);
|
const char* blob_id = JS_AtomToCString(context, ptab[i].atom);
|
||||||
JSPropertyDescriptor desc;
|
JSPropertyDescriptor desc;
|
||||||
JSValue key_value = JS_NULL;
|
JSValue key_value = JS_NULL;
|
||||||
if (JS_GetOwnProperty(context, &desc, args, ptab[i].atom) == 1)
|
if (JS_GetOwnProperty(context, &desc, args, ptab[i].atom) == 1)
|
||||||
@ -725,7 +725,6 @@ static void _tf_ssb_rpc_connection_blobs_createWants_callback(
|
|||||||
JS_FreeValue(context, desc.setter);
|
JS_FreeValue(context, desc.setter);
|
||||||
JS_FreeValue(context, desc.getter);
|
JS_FreeValue(context, desc.getter);
|
||||||
}
|
}
|
||||||
const char* blob_id = JS_ToCString(context, key);
|
|
||||||
int64_t size = 0;
|
int64_t size = 0;
|
||||||
JS_ToInt64(context, &size, key_value);
|
JS_ToInt64(context, &size, key_value);
|
||||||
if (--blob_wants->wants_sent == 0)
|
if (--blob_wants->wants_sent == 0)
|
||||||
@ -750,7 +749,6 @@ static void _tf_ssb_rpc_connection_blobs_createWants_callback(
|
|||||||
tf_ssb_connection_schedule_idle(connection, blob_id, _tf_ssb_rpc_connection_blobs_get_idle, get);
|
tf_ssb_connection_schedule_idle(connection, blob_id, _tf_ssb_rpc_connection_blobs_get_idle, get);
|
||||||
}
|
}
|
||||||
JS_FreeCString(context, blob_id);
|
JS_FreeCString(context, blob_id);
|
||||||
JS_FreeValue(context, key);
|
|
||||||
JS_FreeValue(context, key_value);
|
JS_FreeValue(context, key_value);
|
||||||
}
|
}
|
||||||
for (uint32_t i = 0; i < plen; ++i)
|
for (uint32_t i = 0; i < plen; ++i)
|
||||||
@ -1719,7 +1717,7 @@ static void _tf_ssb_rpc_peers_exchange_internal(
|
|||||||
{
|
{
|
||||||
for (uint32_t i = 0; i < plen; ++i)
|
for (uint32_t i = 0; i < plen; ++i)
|
||||||
{
|
{
|
||||||
JSValue key = JS_AtomToString(context, ptab[i].atom);
|
const char* connection = JS_AtomToCString(context, ptab[i].atom);
|
||||||
JSPropertyDescriptor desc;
|
JSPropertyDescriptor desc;
|
||||||
JSValue key_value = JS_NULL;
|
JSValue key_value = JS_NULL;
|
||||||
if (JS_GetOwnProperty(context, &desc, args, ptab[i].atom) == 1)
|
if (JS_GetOwnProperty(context, &desc, args, ptab[i].atom) == 1)
|
||||||
@ -1728,12 +1726,10 @@ static void _tf_ssb_rpc_peers_exchange_internal(
|
|||||||
JS_FreeValue(context, desc.setter);
|
JS_FreeValue(context, desc.setter);
|
||||||
JS_FreeValue(context, desc.getter);
|
JS_FreeValue(context, desc.getter);
|
||||||
}
|
}
|
||||||
const char* connection = JS_ToCString(context, key);
|
|
||||||
int64_t timestamp = 0;
|
int64_t timestamp = 0;
|
||||||
JS_ToInt64(context, ×tamp, key_value);
|
JS_ToInt64(context, ×tamp, key_value);
|
||||||
/* ADD BROADCAST connection: timestamp */
|
/* ADD BROADCAST connection: timestamp */
|
||||||
JS_FreeCString(context, connection);
|
JS_FreeCString(context, connection);
|
||||||
JS_FreeValue(context, key);
|
|
||||||
JS_FreeValue(context, key_value);
|
JS_FreeValue(context, key_value);
|
||||||
}
|
}
|
||||||
for (uint32_t i = 0; i < plen; ++i)
|
for (uint32_t i = 0; i < plen; ++i)
|
||||||
|
Reference in New Issue
Block a user