Coverage Report

Created: 2025-04-22 06:17

/src/neomutt/mh/mhemail.c
Line
Count
Source (jump to first uncovered line)
1
/**
2
 * @file
3
 * Mh Email helper
4
 *
5
 * @authors
6
 * Copyright (C) 2023 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 mh_mdemail Mh Email helper
25
 *
26
 * Mh Email helper
27
 */
28
29
#include "config.h"
30
#include <stddef.h>
31
#include "mutt/lib.h"
32
#include "email/lib.h"
33
#include "mhemail.h"
34
35
/**
36
 * mh_entry_new - Create a new Mh entry
37
 * @retval ptr New Mh entry
38
 */
39
struct MhEmail *mh_entry_new(void)
40
0
{
41
0
  return MUTT_MEM_CALLOC(1, struct MhEmail);
42
0
}
43
44
/**
45
 * mh_entry_free - Free a Mh object
46
 * @param[out] ptr Mh to free
47
 */
48
void mh_entry_free(struct MhEmail **ptr)
49
0
{
50
0
  if (!ptr || !*ptr)
51
0
    return;
52
53
0
  struct MhEmail *md = *ptr;
54
0
  FREE(&md->canon_fname);
55
0
  email_free(&md->email);
56
57
0
  FREE(ptr);
58
0
}
59
60
/**
61
 * mharray_clear - Free a Mh array
62
 * @param[out] mha Mh array to free
63
 */
64
void mharray_clear(struct MhEmailArray *mha)
65
0
{
66
0
  if (!mha)
67
0
    return;
68
69
0
  struct MhEmail **mdp = NULL;
70
0
  ARRAY_FOREACH(mdp, mha)
71
0
  {
72
0
    mh_entry_free(mdp);
73
0
  }
74
75
0
  ARRAY_FREE(mha);
76
0
}