diff --git a/src/httpd.js.c b/src/httpd.js.c index ab2f5c25..6a8b46f3 100644 --- a/src/httpd.js.c +++ b/src/httpd.js.c @@ -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); for (; count < (int)plen && count < headers_length / 2; ++count) { - JSValue key = JS_AtomToString(context, ptab[count].atom); JSPropertyDescriptor desc; JSValue key_value = JS_NULL; 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.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); - JS_FreeValue(context, key); JS_FreeValue(context, key_value); } for (uint32_t i = 0; i < plen; ++i) diff --git a/src/ssb.ebt.c b/src/ssb.ebt.c index 8d37fe54..b882759a 100644 --- a/src/ssb.ebt.c +++ b/src/ssb.ebt.c @@ -127,8 +127,7 @@ void tf_ssb_ebt_receive_clock(tf_ssb_ebt_t* ebt, JSContext* context, JSValue clo } if (!JS_IsUndefined(in_clock)) { - JSValue key = JS_AtomToString(context, ptab[i].atom); - const char* author = JS_ToCString(context, key); + const char* author = JS_AtomToCString(context, ptab[i].atom); int64_t sequence = -1; 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_FreeValue(context, key); } JS_FreeValue(context, in_clock); } diff --git a/src/ssb.export.c b/src/ssb.export.c index a63e749c..c23e3c13 100644 --- a/src/ssb.export.c +++ b/src/ssb.export.c @@ -142,8 +142,7 @@ void tf_ssb_export(tf_ssb_t* ssb, const char* key) JSPropertyDescriptor desc; if (JS_GetOwnProperty(context, &desc, files, ptab[i].atom) == 1) { - JSValue key = JS_AtomToString(context, ptab[i].atom); - const char* file_name = JS_ToCString(context, key); + const char* file_name = JS_AtomToCString(context, ptab[i].atom); const char* blob_id = JS_ToCString(context, desc.value); 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_FreeValue(context, key); JS_FreeCString(context, blob_id); JS_FreeValue(context, desc.value); JS_FreeValue(context, desc.setter); diff --git a/src/ssb.rpc.c b/src/ssb.rpc.c index eb1409f8..28aaf69c 100644 --- a/src/ssb.rpc.c +++ b/src/ssb.rpc.c @@ -716,7 +716,7 @@ static void _tf_ssb_rpc_connection_blobs_createWants_callback( { 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; JSValue key_value = JS_NULL; 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.getter); } - const char* blob_id = JS_ToCString(context, key); int64_t size = 0; JS_ToInt64(context, &size, key_value); 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); } JS_FreeCString(context, blob_id); - JS_FreeValue(context, key); JS_FreeValue(context, key_value); } 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) { - JSValue key = JS_AtomToString(context, ptab[i].atom); + const char* connection = JS_AtomToCString(context, ptab[i].atom); JSPropertyDescriptor desc; JSValue key_value = JS_NULL; 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.getter); } - const char* connection = JS_ToCString(context, key); int64_t timestamp = 0; JS_ToInt64(context, ×tamp, key_value); /* ADD BROADCAST connection: timestamp */ JS_FreeCString(context, connection); - JS_FreeValue(context, key); JS_FreeValue(context, key_value); } for (uint32_t i = 0; i < plen; ++i)