]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
cleanup: use dprintf earlier to avoid temporary memory allocation
authorBaptiste Daroussin <bapt@FreeBSD.org>
Tue, 2 Nov 2021 14:22:14 +0000 (15:22 +0100)
committerBaptiste Daroussin <bapt@FreeBSD.org>
Wed, 3 Nov 2021 13:10:28 +0000 (14:10 +0100)
src/send_digest.c

index ef8d5cecb97d6c43ab6a70559deb9ad4990024de..4c38d69661e53500b1e4c7c1989acb7aadedc37e 100644 (file)
@@ -237,7 +237,7 @@ static void finish_thread_list(thread_list_state * s)
 int send_digest(struct mlmmj_list *list, int firstindex, int lastindex,
                int issue, const char *addr, const char *mlmmjsend)
 {
-       int i, fd, archivefd, status, hdrfd;
+       int i, fd, archivefd, status, hdrfd, r;
        size_t len;
        text * txt;
        char buf[100];
@@ -361,20 +361,16 @@ fallback_subject:
                myfree(tmp);
        }
 
-       tmp = concatstr(10, "From: ", list->name, list->delim, "help@", list->fqdn,
+       r = dprintf(fd, "From: %s%shelp@%s"
                           "\nMIME-Version: 1.0"
                           "\nContent-Type: multipart/" DIGESTMIMETYPE "; "
-                          "boundary=", boundary,
-                          "\nSubject: ", subject,
-                          "\n");
-
+                          "boundary=%s"
+                          "\nSubject: %s\n",
+                          list->name, list->delim, list->fqdn, boundary, subject);
        myfree(subject);
 
-       if (dprintf(fd, "%s", tmp) < 0) {
-               myfree(tmp);
+       if (r < 0)
                goto errdighdrs;
-       }
-       myfree(tmp);
 
        if(hdrfd >= 0 && dumpfd2fd(hdrfd, fd) < 0) {
                goto errdighdrs;