diff --git a/activitypub.c b/activitypub.c index a0b33ee..0ee0bf6 100644 --- a/activitypub.c +++ b/activitypub.c @@ -123,7 +123,7 @@ int send_to_inbox(snac *snac, char *inbox, char *msg, d_char **payload, int *p_s response = http_signed_request(snac, "POST", inbox, NULL, j_msg, strlen(j_msg), &status, payload, p_size); - free(response); + xs_free(response); return status; } @@ -553,7 +553,7 @@ d_char *msg_note(snac *snac, char *content, char *rcpts, char *in_reply_to, char /* if this message is public, ours will also be */ if (is_msg_public(snac, p_msg) && - xs_list_in(to, (char *)public_address) == -1) + xs_list_in(to, public_address) == -1) to = xs_list_append(to, public_address); } diff --git a/data.c b/data.c index c913b52..39f7efb 100644 --- a/data.c +++ b/data.c @@ -526,10 +526,10 @@ void _timeline_write(snac *snac, char *id, char *msg, char *parent, char *referr fclose(f); xs *g_msg = xs_json_loads(j); - d_char *meta = xs_dict_get(g_msg, "_snac"); - d_char *p = xs_dict_get(meta, "parent"); + char *meta = xs_dict_get(g_msg, "_snac"); + char *p = xs_dict_get(meta, "parent"); - free(grampa); + xs_free(grampa); grampa = xs_dup(p); } } diff --git a/httpd.c b/httpd.c index d7fad93..726cb37 100644 --- a/httpd.c +++ b/httpd.c @@ -183,10 +183,8 @@ void httpd_connection(FILE *f) b_size = strlen(body); /* if it was a HEAD, no body will be sent */ - if (strcmp(method, "HEAD") == 0) { - free(body); - body = NULL; - } + if (strcmp(method, "HEAD") == 0) + body = xs_free(body); xs_httpd_response(f, status, headers, body, b_size); @@ -194,7 +192,7 @@ void httpd_connection(FILE *f) srv_archive("RECV", req, payload, p_size, status, headers, body, b_size); - free(body); + xs_free(body); } @@ -233,18 +231,21 @@ static void *queue_thread(void *arg) srv_log(xs_fmt("queue thread start")); while (srv_running) { - xs *list = user_list(); - char *p, *uid; time_t t; - /* process queues for all users */ - p = list; - while (xs_list_iter(&p, &uid)) { - snac snac; + { + xs *list = user_list(); + char *p, *uid; - if (user_open(&snac, uid)) { - process_queue(&snac); - user_free(&snac); + /* process queues for all users */ + p = list; + while (xs_list_iter(&p, &uid)) { + snac snac; + + if (user_open(&snac, uid)) { + process_queue(&snac); + user_free(&snac); + } } } diff --git a/xs.h b/xs.h index 7900ea0..5aed922 100644 --- a/xs.h +++ b/xs.h @@ -66,7 +66,7 @@ d_char *xs_list_append_m(d_char *list, const char *mem, int dsz); int xs_list_iter(char **list, char **value); int xs_list_len(char *list); char *xs_list_get(char *list, int num); -int xs_list_in(char *list, char *val); +int xs_list_in(char *list, const char *val); d_char *xs_join(char *list, const char *sep); d_char *xs_split_n(const char *str, const char *sep, int times); #define xs_split(str, sep) xs_split_n(str, sep, 0xfffffff) @@ -96,12 +96,27 @@ void *_xs_realloc(void *ptr, size_t size, const char *file, int line, const char #ifdef XS_DEBUG if (ndata != ptr) { + int n; FILE *f = fopen("xs_memory.out", "a"); if (ptr != NULL) fprintf(f, "%p r\n", ptr); - fprintf(f, "%p a %ld %s %d %s\n", ndata, size, file, line, func); + fprintf(f, "%p a %ld %s:%d: %s", ndata, size, file, line, func); + + if (ptr != NULL) { + fprintf(f, " ["); + for (n = 0; n < 32 && ndata[n]; n++) { + if (ndata[n] >= 32 && ndata[n] <= 127) + fprintf(f, "%c", ndata[n]); + else + fprintf(f, "\\%02x", (unsigned char)ndata[n]); + } + fprintf(f, "]"); + } + + fprintf(f, "\n"); + fclose(f); } #endif @@ -531,7 +546,7 @@ char *xs_list_get(char *list, int num) } -int xs_list_in(char *list, char *val) +int xs_list_in(char *list, const char *val) /* returns the position of val in list or -1 */ { int n = 0; diff --git a/xs_version.h b/xs_version.h index 4ed093c..8a9d469 100644 --- a/xs_version.h +++ b/xs_version.h @@ -1 +1 @@ -/* 286f556255aa224a72b778c44b837b75170becf5 */ +/* 870b15e48a153ac601046ac2dc72dd8ccb0c77a4 */