commit 56816b3

grunfink  ·  2025-05-22 09:18:48 +0000 UTC
parent 096bb21
Minor memory leak fixes.
4 files changed,  +7, -7
M data.c
+1, -1
1@@ -903,7 +903,7 @@ xs_str *process_tags(snac *snac, const char *content, xs_list **tag)
2             if (*v == '#') {
3                 /* hashtag */
4                 xs *d = xs_dict_new();
5-                xs *n = xs_utf8_to_lower(xs_dup(v));
6+                xs *n = xs_utf8_to_lower(v);
7                 xs *h = xs_fmt("%s?t=%s", srv_baseurl, n + 1);
8                 xs *l = xs_fmt("<a href=\"%s\" class=\"mention hashtag\" rel=\"tag\">%s</a>", h, v);
9 
M data.c
+4, -4
 1@@ -2247,7 +2247,7 @@ xs_str *tag_fn(const char *tag)
 2     if (*tag == '#')
 3         tag++;
 4 
 5-    xs *lw_tag = xs_utf8_to_lower(xs_dup(tag));
 6+    xs *lw_tag = xs_utf8_to_lower(tag);
 7     xs *md5    = xs_md5_hex(lw_tag, strlen(lw_tag));
 8 
 9     return xs_fmt("%s/tag/%c%c/%s.idx", srv_basedir, md5[0], md5[1], md5);
10@@ -2832,9 +2832,9 @@ int content_match(const char *file, const xs_dict *msg)
11             srv_debug(1, xs_fmt("content_match: loading regexes from %s", fn));
12 
13             /* massage content (strip HTML tags, etc.) */
14-            xs *c = xs_regex_replace(v, "<[^>]+>", " ");
15-            c = xs_regex_replace_i(c, " {2,}", " ");
16-            c = xs_utf8_to_lower(c);
17+            xs *c1 = xs_regex_replace(v, "<[^>]+>", " ");
18+            c1 = xs_regex_replace_i(c1, " {2,}", " ");
19+            xs *c = xs_utf8_to_lower(c1);
20 
21             while (!r && !feof(f)) {
22                 xs *rx = xs_strip_i(xs_readline(f));
+1, -1
1@@ -444,7 +444,7 @@ xs_str *sanitize(const char *content)
2         if (n & 0x1) {
3             xs *s1  = xs_strip_i(xs_crop_i(xs_dup(v), v[1] == '/' ? 2 : 1, -1));
4             xs *l1  = xs_split_n(s1, " ", 1);
5-            xs *tag = xs_utf8_to_lower(xs_dup(xs_list_get(l1, 0)));
6+            xs *tag = xs_utf8_to_lower(xs_list_get(l1, 0));
7             xs *s2  = NULL;
8             int i;
9 
+1, -1
1@@ -1638,7 +1638,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
2                 const char *aq = xs_dict_get(args, "q");
3 
4                 if (!xs_is_null(aq)) {
5-                    xs *q    = xs_utf8_to_lower(xs_dup(aq));
6+                    xs *q    = xs_utf8_to_lower(aq);
7                     out      = xs_list_new();
8                     xs *wing = following_list(&snac1);
9                     xs *wers = follower_list(&snac1);