summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordefault <nobody@localhost>2023-08-13 12:09:35 +0200
committerdefault <nobody@localhost>2023-08-13 12:09:35 +0200
commita0906208ea3906b3820307aa4bfe811b8d2eadb6 (patch)
treee5cf16535586b3e197cb72141009b620f5ab0fc5
parent5bec358fa0f7d6652e732878567936752c26a827 (diff)
Use some new xs_stock values.
-rw-r--r--activitypub.c6
-rw-r--r--mastoapi.c15
-rw-r--r--xs.h9
-rw-r--r--xs_version.h2
4 files changed, 17 insertions, 15 deletions
diff --git a/activitypub.c b/activitypub.c
index 6fb6bf5..8b80683 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -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);
}
}
diff --git a/mastoapi.c b/mastoapi.c
index b6a0e49..99e78ea 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -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);
diff --git a/xs.h b/xs.h
index 35ddba8..a9064e0 100644
--- a/xs.h
+++ b/xs.h
@@ -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)
{
diff --git a/xs_version.h b/xs_version.h
index 1a7656a..0fd2972 100644
--- a/xs_version.h
+++ b/xs_version.h
@@ -1 +1 @@
-/* 59b0a9da6a6b6258ab003ab71d790d2879cd2e31 */
+/* 6cb05184b1aafc2740758de5422d70df51e01b66 */