Coverage Report

Created: 2023-06-07 06:15

/src/neomutt/imap/edata.c
Line
Count
Source (jump to first uncovered line)
1
/**
2
 * @file
3
 * Imap-specific Email data
4
 *
5
 * @authors
6
 * Copyright (C) 2021 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 imap_edata Imap-specific Email data
25
 *
26
 * Imap-specific Email data
27
 */
28
29
#include "config.h"
30
#include <stddef.h>
31
#include <string.h>
32
#include "mutt/lib.h"
33
#include "email/lib.h"
34
#include "edata.h"
35
36
/**
37
 * imap_edata_free - Free the private Email data - Implements Email::edata_free()
38
 */
39
void imap_edata_free(void **ptr)
40
0
{
41
0
  if (!ptr || !*ptr)
42
0
    return;
43
44
0
  struct ImapEmailData *edata = *ptr;
45
  /* this should be safe even if the list wasn't used */
46
0
  FREE(&edata->flags_system);
47
0
  FREE(&edata->flags_remote);
48
0
  FREE(ptr);
49
0
}
50
51
/**
52
 * imap_edata_new - Create a new ImapEmailData
53
 * @retval ptr New ImapEmailData
54
 */
55
struct ImapEmailData *imap_edata_new(void)
56
0
{
57
0
  return mutt_mem_calloc(1, sizeof(struct ImapEmailData));
58
0
}
59
60
/**
61
 * imap_edata_get - Get the private data for this Email
62
 * @param e Email
63
 * @retval ptr Private Email data
64
 */
65
struct ImapEmailData *imap_edata_get(struct Email *e)
66
0
{
67
0
  if (!e)
68
0
    return NULL;
69
0
  return e->edata;
70
0
}
71
72
/**
73
 * imap_edata_clone - Clone an ImapEmailData
74
 * @param src The source ImapEmailData to clone
75
 * @retval ptr New ImapEmailData
76
 */
77
struct ImapEmailData *imap_edata_clone(struct ImapEmailData *src)
78
0
{
79
0
  struct ImapEmailData *dst = imap_edata_new();
80
0
  memcpy(dst, src, sizeof(*src));
81
0
  dst->flags_system = mutt_str_dup(src->flags_system);
82
0
  dst->flags_remote = mutt_str_dup(src->flags_remote);
83
0
  return dst;
84
0
}