Coverage Report

Created: 2023-09-25 07:17

/src/neomutt/maildir/mdemail.c
Line
Count
Source (jump to first uncovered line)
1
/**
2
 * @file
3
 * Maildir Email helper
4
 *
5
 * @authors
6
 * Copyright (C) 2020 Richard Russon <rich@flatcap.org>
7
 *
8
 * @copyright
9
 * This program is free software: you can redistribute it and/or modify it under
10
 * the terms of the GNU General Public License as published by the Free Software
11
 * Foundation, either version 2 of the License, or (at your option) any later
12
 * version.
13
 *
14
 * This program is distributed in the hope that it will be useful, but WITHOUT
15
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
17
 * details.
18
 *
19
 * You should have received a copy of the GNU General Public License along with
20
 * this program.  If not, see <http://www.gnu.org/licenses/>.
21
 */
22
23
/**
24
 * @page maildir_mdemail Maildir Email helper
25
 *
26
 * Maildir Email helper
27
 */
28
29
#include "config.h"
30
#include <stddef.h>
31
#include "mutt/lib.h"
32
#include "email/lib.h"
33
#include "mdemail.h"
34
35
/**
36
 * maildir_entry_new - Create a new Maildir entry
37
 * @retval ptr New Maildir entry
38
 */
39
struct MdEmail *maildir_entry_new(void)
40
0
{
41
0
  return mutt_mem_calloc(1, sizeof(struct MdEmail));
42
0
}
43
44
/**
45
 * maildir_entry_free - Free a Maildir object
46
 * @param[out] ptr Maildir to free
47
 */
48
void maildir_entry_free(struct MdEmail **ptr)
49
0
{
50
0
  if (!ptr || !*ptr)
51
0
    return;
52
53
0
  struct MdEmail *md = *ptr;
54
0
  FREE(&md->canon_fname);
55
0
  email_free(&md->email);
56
57
0
  FREE(ptr);
58
0
}
59
60
/**
61
 * maildirarray_clear - Free a Maildir array
62
 * @param[out] mda Maildir array to free
63
 */
64
void maildirarray_clear(struct MdEmailArray *mda)
65
0
{
66
0
  if (!mda)
67
0
    return;
68
69
0
  struct MdEmail **mdp = NULL;
70
0
  ARRAY_FOREACH(mdp, mda)
71
0
  {
72
0
    maildir_entry_free(mdp);
73
0
  }
74
75
0
  ARRAY_FREE(mda);
76
0
}