Coverage Report

Created: 2026-04-12 06:26

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libexif/libexif/exif-mnote-data.c
Line
Count
Source
1
/* exif-mnote-data.c
2
 *
3
 * Copyright (C) 2003 Lutz Mueller <lutz@users.sourceforge.net>
4
 *
5
 * This library is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU Lesser General Public
7
 * License as published by the Free Software Foundation; either
8
 * version 2.1 of the License, or (at your option) any later version.
9
 *
10
 * This library is distributed in the hope that it will be useful, 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 * Lesser General Public License for more details. 
14
 *
15
 * You should have received a copy of the GNU Lesser General Public
16
 * License along with this library; if not, write to the
17
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18
 * Boston, MA  02110-1301  USA.
19
 *
20
 * SPDX-License-Identifier: LGPL-2.1-or-later
21
 */
22
23
#include <config.h>
24
25
#include <libexif/exif-mnote-data.h>
26
#include <libexif/exif-mnote-data-priv.h>
27
28
#include <stdlib.h>
29
#include <string.h>
30
31
struct _ExifMnoteDataPriv
32
{
33
  unsigned int ref_count;
34
};
35
36
void
37
exif_mnote_data_construct (ExifMnoteData *d, ExifMem *mem)
38
13.6k
{
39
13.6k
  if (!d || !mem) return;
40
13.6k
  if (d->priv) return;
41
13.6k
  d->priv = exif_mem_alloc (mem, sizeof (ExifMnoteDataPriv));
42
13.6k
  if (!d->priv) return;
43
44
13.6k
  d->priv->ref_count = 1;
45
46
13.6k
  d->mem = mem;
47
13.6k
  exif_mem_ref (mem);
48
13.6k
}
49
50
void
51
exif_mnote_data_ref (ExifMnoteData *d)
52
6.37k
{
53
6.37k
  if (d && d->priv) d->priv->ref_count++;
54
6.37k
}
55
56
static void
57
exif_mnote_data_free (ExifMnoteData *d)
58
13.6k
{
59
13.6k
  ExifMem *mem = d ? d->mem : NULL;
60
61
13.6k
  if (!d) return;
62
13.6k
  if (d->priv) {
63
13.6k
    if (d->methods.free) d->methods.free (d);
64
13.6k
    exif_mem_free (mem, d->priv);
65
13.6k
    d->priv = NULL;
66
13.6k
  }
67
13.6k
  exif_log_unref (d->log);
68
13.6k
  exif_mem_free (mem, d);
69
13.6k
  exif_mem_unref (mem);
70
13.6k
}
71
72
void
73
exif_mnote_data_unref (ExifMnoteData *d)
74
19.9k
{
75
19.9k
  if (!d || !d->priv) return;
76
19.9k
  if (d->priv->ref_count > 0) d->priv->ref_count--;
77
19.9k
  if (!d->priv->ref_count)
78
13.6k
    exif_mnote_data_free (d);
79
19.9k
}
80
81
void
82
exif_mnote_data_load (ExifMnoteData *d, const unsigned char *buf,
83
          unsigned int buf_size)
84
13.6k
{
85
13.6k
  if (!d || !d->methods.load) return;
86
13.6k
  d->methods.load (d, buf, buf_size);
87
13.6k
}
88
89
void
90
exif_mnote_data_save (ExifMnoteData *d, unsigned char **buf,
91
          unsigned int *buf_size)
92
7.24k
{
93
7.24k
  if (!d || !d->methods.save) return;
94
7.24k
  d->methods.save (d, buf, buf_size);
95
7.24k
}
96
97
void
98
exif_mnote_data_set_byte_order (ExifMnoteData *d, ExifByteOrder o)
99
13.6k
{
100
13.6k
  if (!d || !d->methods.set_byte_order) return;
101
13.6k
  d->methods.set_byte_order (d, o);
102
13.6k
}
103
104
void
105
exif_mnote_data_set_offset (ExifMnoteData *d, unsigned int o)
106
20.8k
{
107
20.8k
  if (!d || !d->methods.set_offset) return;
108
20.8k
  d->methods.set_offset (d, o);
109
20.8k
}
110
111
unsigned int
112
exif_mnote_data_count (ExifMnoteData *d)
113
13.6k
{
114
13.6k
  if (!d || !d->methods.count) return 0;
115
13.6k
  return d->methods.count (d);
116
13.6k
}
117
118
unsigned int
119
exif_mnote_data_get_id (ExifMnoteData *d, unsigned int n)
120
0
{
121
0
  if (!d || !d->methods.get_id) return 0;
122
0
  return d->methods.get_id (d, n);
123
0
}
124
125
const char *
126
exif_mnote_data_get_name (ExifMnoteData *d, unsigned int n)
127
1.29M
{
128
1.29M
  if (!d || !d->methods.get_name) return NULL;
129
1.29M
  return d->methods.get_name (d, n);
130
1.29M
}
131
132
const char *
133
exif_mnote_data_get_title (ExifMnoteData *d, unsigned int n)
134
1.29M
{
135
1.29M
  if (!d || !d->methods.get_title) return NULL;
136
1.29M
  return d->methods.get_title (d, n);
137
1.29M
}
138
  
139
const char *
140
exif_mnote_data_get_description (ExifMnoteData *d, unsigned int n)
141
1.29M
{
142
1.29M
  if (!d || !d->methods.get_description) return NULL;
143
1.29M
  return d->methods.get_description (d, n);
144
1.29M
}
145
  
146
char *
147
exif_mnote_data_get_value (ExifMnoteData *d, unsigned int n, char *val, unsigned int maxlen)
148
21.9M
{
149
21.9M
  if (!d || !d->methods.get_value) return NULL;
150
21.9M
  return d->methods.get_value (d, n, val, maxlen);
151
21.9M
}
152
153
void
154
exif_mnote_data_log (ExifMnoteData *d, ExifLog *log)
155
13.6k
{
156
13.6k
  if (!d) return;
157
13.6k
  exif_log_unref (d->log);
158
13.6k
  d->log = log;
159
13.6k
  exif_log_ref (log);
160
13.6k
}