commit 1af75030881741bb67be1413159ae52883481feb
parent 15fab62468e9586e98d89e940cfdf8bc0974a97d
Author: Mario Rosell R. Martinez <mario@mariorosell.es>
Date: Sat, 28 Mar 2026 21:21:55 +0100
anntp_article: Add anntp_free_article
Diffstat:
| M | anntp.h | | | 30 | ++++++++++++++++++++++++++++++ |
1 file changed, 30 insertions(+), 0 deletions(-)
diff --git a/anntp.h b/anntp.h
@@ -194,6 +194,7 @@ ANNTP_API ssize_t anntp_read(AnntpConnection* conn, uchar_t* buf, size_
ANNTP_API ssize_t anntp_write(AnntpConnection* conn, const uchar_t* buf, size_t bufsize);
ANNTP_API int anntp_group(AnntpConnection* conn, const char* group, AnntpGroup* out_group);
ANNTP_API ssize_t anntp_article(AnntpConnection*, size_t num, AnntpArticle* out_art);
+ANNTP_API void anntp_article_free(AnntpArticle* art);
ANNTP_API ssize_t anntp_write_all(AnntpConnection* conn, const uchar_t* buf, size_t bufsize);
ANNTP_API ssize_t anntp_writeline(AnntpConnection* conn, const char* buf);
ANNTP_API ssize_t anntp_readline(AnntpConnection* conn, char* buf, size_t maxlen);
@@ -390,6 +391,35 @@ anntp_article(AnntpConnection* cv, size_t n, AnntpArticle* art)
return (ssize_t)len;
}
+ANNTP_API void
+anntp_article_free(AnntpArticle* art)
+{
+ if (!art)
+ return;
+
+ if (art->id) {
+ ANNTP_FREE(art->id);
+ art->id = NULL;
+ }
+
+ if (art->from) {
+ ANNTP_FREE(art->from);
+ art->from = NULL;
+ }
+
+ if (art->date) {
+ ANNTP_FREE(art->date);
+ art->date = NULL;
+ }
+
+ if (art->body) {
+ ANNTP_FREE(art->body);
+ art->body = NULL;
+ }
+
+ art->n = 0;
+}
+
void
anntp_freeconn(AnntpConnection* cv)
{