forked from cory/tildefriends
Add a helper for getting array length: tf_util_get_length.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3925 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
#include "mem.h"
|
||||
#include "ssb.db.h"
|
||||
#include "ssb.h"
|
||||
#include "util.js.h"
|
||||
|
||||
#include <quickjs.h>
|
||||
#include <stdlib.h>
|
||||
@ -51,10 +52,7 @@ static void _tf_ssb_import_add_app(tf_ssb_t* ssb, const char* user, const char*
|
||||
JS_FreeValue(context, apps);
|
||||
apps = JS_NewArray(context);
|
||||
}
|
||||
int32_t length = 0;
|
||||
JSValue lengthval = JS_GetPropertyStr(context, apps, "length");
|
||||
JS_ToInt32(context, &length, lengthval);
|
||||
JS_FreeValue(context, lengthval);
|
||||
int32_t length = tf_util_get_length(context, apps);;
|
||||
JS_SetPropertyUint32(context, apps, length, JS_NewString(context, app));
|
||||
|
||||
JSValue json = JS_JSONStringify(context, apps, JS_NULL, JS_NULL);
|
||||
|
Reference in New Issue
Block a user