changeset 724:787a27180b9e

post: clear out the tags, cats, and comments on post refresh Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Fri, 09 Oct 2015 16:57:22 -0400
parents 6aadd2124468
children 05b4b162baa4
files post.c
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/post.c	Fri Oct 09 16:13:23 2015 -0400
+++ b/post.c	Fri Oct 09 16:57:22 2015 -0400
@@ -47,6 +47,9 @@
 static umem_cache_t *post_cache;
 static umem_cache_t *comment_cache;
 
+static void post_remove_all_tags(avl_tree_t *taglist);
+static void post_remove_all_comments(struct post *post);
+
 static int tag_cmp(const void *va, const void *vb)
 {
 	const struct post_tag *a = va;
@@ -473,6 +476,12 @@
 
 	__refresh_published_prop(post, lv);
 
+	/* empty out the tags/cats/comments lists */
+	post_remove_all_tags(&post->tags);
+	post_remove_all_tags(&post->cats);
+	post_remove_all_comments(post);
+
+	/* populate the tags/cats/comments lists */
 	post_add_tags(&post->tags, lisp_lookup_list(lv, "tags"));
 	post_add_tags(&post->cats, lisp_lookup_list(lv, "cats"));
 	post_add_comments(post, lisp_lookup_list(lv, "comments"));