From 6b0d65ef71a1ccfc295b4ef8ff733f21dab51c55 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Fri, 3 Jun 2011 00:54:39 -0400 Subject: [PATCH] Separate blogpost renderer/destructor into different functions --- webcit/blogview_renderer.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/webcit/blogview_renderer.c b/webcit/blogview_renderer.c index c0dafd9ea..a303396d9 100644 --- a/webcit/blogview_renderer.c +++ b/webcit/blogview_renderer.c @@ -44,11 +44,9 @@ void tmplput_blog_permalink(StrBuf *Target, WCTemplputParams *TP) { /* - * Destructor for 'struct blogpost' which does the rendering first. - * By rendering from here, we eliminate the need for a separate iterator, although - * we might run into trouble when we get around to displaying newest-to-oldest... + * Render (maybe) a single blog post and (maybe) its comments */ -void blogpost_render_and_destroy(struct blogpost *bp) { +void blogpost_render(struct blogpost *bp) { const StrBuf *Mime; int p = 0; int i; @@ -87,16 +85,21 @@ void blogpost_render_and_destroy(struct blogpost *bp) { } } - - if (bp->alloc_msgs > 0) { - free(bp->msgs); - } - /* offer the comment box */ if (p == bp->top_level_id) { do_template("blog_comment_box"); } +} + + +/* + * Destructor for "struct blogpost" + */ +void blogpost_destroy(struct blogpost *bp) { + if (bp->alloc_msgs > 0) { + free(bp->msgs); + } free(bp); } @@ -187,8 +190,7 @@ int blogview_LoadMsgFromServer(SharedMessageStatus *Stat, if (!bp) return(200); memset(bp, 0, sizeof (struct blogpost)); bp->top_level_id = b.id; - Put(BLOG, (const char *)&b.id, sizeof(b.id), bp, - (DeleteHashDataFunc)blogpost_render_and_destroy); + Put(BLOG, (const char *)&b.id, sizeof(b.id), bp, (DeleteHashDataFunc)blogpost_destroy); } else { GetHash(BLOG, (const char *)&b.refs , sizeof(b.refs), (void *)&bp); @@ -253,6 +255,7 @@ int blogview_render(SharedMessageStatus *Stat, void **ViewSpecific, long oper) wc_printf("; top level msgnum is %ld", bp->msgs[0]); } wc_printf("
\n"); + blogpost_render(bp); } DeleteHashPos(&it); -- 2.30.2