js: Fix database.getall().
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 16m6s
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 16m6s
This commit is contained in:
parent
e979c176e3
commit
0a35e14590
@ -390,8 +390,6 @@ static JSValue _database_remove(JSContext* context, JSValueConst this_val, int a
|
|||||||
typedef struct _database_get_all_t
|
typedef struct _database_get_all_t
|
||||||
{
|
{
|
||||||
const char* id;
|
const char* id;
|
||||||
const char* key;
|
|
||||||
size_t key_length;
|
|
||||||
char** out_values;
|
char** out_values;
|
||||||
size_t* out_lengths;
|
size_t* out_lengths;
|
||||||
int out_values_length;
|
int out_values_length;
|
||||||
@ -455,17 +453,11 @@ static JSValue _database_get_all(JSContext* context, JSValueConst this_val, int
|
|||||||
{
|
{
|
||||||
tf_ssb_t* ssb = tf_task_get_ssb(database->task);
|
tf_ssb_t* ssb = tf_task_get_ssb(database->task);
|
||||||
|
|
||||||
size_t length;
|
database_get_all_t* work = tf_malloc(sizeof(database_get_all_t) + strlen(database->id) + 1);
|
||||||
const char* key = JS_ToCStringLen(context, &length, argv[0]);
|
|
||||||
database_get_all_t* work = tf_malloc(sizeof(database_get_all_t) + strlen(database->id) + 1 + length + 1);
|
|
||||||
*work = (database_get_all_t) {
|
*work = (database_get_all_t) {
|
||||||
.id = (const char*)(work + 1),
|
.id = (const char*)(work + 1),
|
||||||
.key = (const char*)(work + 1) + strlen(database->id) + 1,
|
|
||||||
.key_length = length,
|
|
||||||
};
|
};
|
||||||
memcpy((char*)work->id, database->id, strlen(database->id) + 1);
|
memcpy((char*)work->id, database->id, strlen(database->id) + 1);
|
||||||
memcpy((char*)work->key, key, length + 1);
|
|
||||||
JS_FreeCString(context, key);
|
|
||||||
|
|
||||||
tf_ssb_run_work(ssb, _database_get_all_work, _database_get_all_after_work, work);
|
tf_ssb_run_work(ssb, _database_get_all_work, _database_get_all_after_work, work);
|
||||||
result = JS_NewPromiseCapability(context, work->promise);
|
result = JS_NewPromiseCapability(context, work->promise);
|
||||||
|
Loading…
Reference in New Issue
Block a user