Use some new xs_stock values.

This commit is contained in:
default 2023-08-13 12:09:35 +02:00
parent 5bec358fa0
commit a0906208ea
4 changed files with 17 additions and 15 deletions

View File

@ -820,11 +820,10 @@ xs_dict *msg_collection(snac *snac, char *id)
{
xs_dict *msg = msg_base(snac, "OrderedCollection", id, NULL, NULL, NULL);
xs *ol = xs_list_new();
xs *nz = xs_number_new(0);
msg = xs_dict_append(msg, "attributedTo", snac->actor);
msg = xs_dict_append(msg, "orderedItems", ol);
msg = xs_dict_append(msg, "totalItems", nz);
msg = xs_dict_append(msg, "totalItems", xs_stock_0);
return msg;
}
@ -1273,7 +1272,6 @@ int update_question(snac *user, const char *id)
{
xs *msg = NULL;
xs *rcnt = xs_dict_new();
xs *z = xs_number_new(0);
xs *lopts = xs_list_new();
xs_list *opts;
xs_list *p;
@ -1298,7 +1296,7 @@ int update_question(snac *user, const char *id)
const char *name = xs_dict_get(v, "name");
if (name) {
lopts = xs_list_append(lopts, name);
rcnt = xs_dict_set(rcnt, name, z);
rcnt = xs_dict_set(rcnt, name, xs_stock_0);
}
}

View File

@ -1462,19 +1462,16 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
ins = xs_dict_append(ins, "email", v);
xs *l1 = xs_list_new();
ins = xs_dict_append(ins, "rules", l1);
ins = xs_dict_append(ins, "rules", xs_stock_list);
l1 = xs_list_append(l1, "en");
xs *l1 = xs_list_append(xs_list_new(), "en");
ins = xs_dict_append(ins, "languages", l1);
xs *d1 = xs_dict_new();
ins = xs_dict_append(ins, "urls", d1);
ins = xs_dict_append(ins, "urls", xs_stock_dict);
xs *z = xs_number_new(0);
xs *d2 = xs_dict_append(xs_dict_new(), "user_count", z);
d2 = xs_dict_append(d2, "status_count", z);
d2 = xs_dict_append(d2, "domain_count", z);
xs *d2 = xs_dict_append(xs_dict_new(), "user_count", xs_stock_0);
d2 = xs_dict_append(d2, "status_count", xs_stock_0);
d2 = xs_dict_append(d2, "domain_count", xs_stock_0);
ins = xs_dict_append(ins, "stats", d2);
ins = xs_dict_append(ins, "registrations", xs_stock_false);

9
xs.h
View File

@ -137,6 +137,10 @@ unsigned int xs_hash_func(const char *data, int size);
extern xs_val xs_stock_null[];
extern xs_val xs_stock_true[];
extern xs_val xs_stock_false[];
extern xs_val xs_stock_0[];
extern xs_val xs_stock_1[];
extern xs_val xs_stock_list[];
extern xs_val xs_stock_dict[];
#define xs_return(v) xs_val *__r = v; v = NULL; return __r
@ -146,7 +150,10 @@ extern xs_val xs_stock_false[];
xs_val xs_stock_null[] = { XSTYPE_NULL };
xs_val xs_stock_true[] = { XSTYPE_TRUE };
xs_val xs_stock_false[] = { XSTYPE_FALSE };
xs_val xs_stock_0[] = { XSTYPE_NUMBER, '0', '\0' };
xs_val xs_stock_1[] = { XSTYPE_NUMBER, '1', '\0' };
xs_val xs_stock_list[] = { XSTYPE_LIST, 0, 0, 5, XSTYPE_EOM };
xs_val xs_stock_dict[] = { XSTYPE_DICT, 0, 0, 5, XSTYPE_EOM };
void *_xs_realloc(void *ptr, size_t size, const char *file, int line, const char *func)
{

View File

@ -1 +1 @@
/* 59b0a9da6a6b6258ab003ab71d790d2879cd2e31 */
/* 6cb05184b1aafc2740758de5422d70df51e01b66 */