Coverage Report

Created: 2025-11-24 06:48

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libwebp/imageio/metadata.c
Line
Count
Source
1
// Copyright 2012 Google Inc. All Rights Reserved.
2
//
3
// Use of this source code is governed by a BSD-style license
4
// that can be found in the COPYING file in the root of the source
5
// tree. An additional intellectual property rights grant can be found
6
// in the file PATENTS. All contributing project authors may
7
// be found in the AUTHORS file in the root of the source tree.
8
// -----------------------------------------------------------------------------
9
//
10
//  Metadata types and functions.
11
//
12
13
#include "./metadata.h"
14
15
#include <stdlib.h>
16
#include <string.h>
17
18
#include "webp/types.h"
19
20
10.0k
void MetadataInit(Metadata* const metadata) {
21
10.0k
  if (metadata == NULL) return;
22
10.0k
  memset(metadata, 0, sizeof(*metadata));
23
10.0k
}
24
25
31.4k
void MetadataPayloadDelete(MetadataPayload* const payload) {
26
31.4k
  if (payload == NULL) return;
27
31.4k
  free(payload->bytes);
28
31.4k
  payload->bytes = NULL;
29
31.4k
  payload->size = 0;
30
31.4k
}
31
32
10.4k
void MetadataFree(Metadata* const metadata) {
33
10.4k
  if (metadata == NULL) return;
34
10.4k
  MetadataPayloadDelete(&metadata->exif);
35
10.4k
  MetadataPayloadDelete(&metadata->iccp);
36
10.4k
  MetadataPayloadDelete(&metadata->xmp);
37
10.4k
}
38
39
int MetadataCopy(const char* metadata, size_t metadata_len,
40
0
                 MetadataPayload* const payload) {
41
0
  if (metadata == NULL || metadata_len == 0 || payload == NULL) return 0;
42
0
  payload->bytes = (uint8_t*)malloc(metadata_len);
43
0
  if (payload->bytes == NULL) return 0;
44
0
  payload->size = metadata_len;
45
0
  memcpy(payload->bytes, metadata, metadata_len);
46
0
  return 1;
47
0
}
48
49
// -----------------------------------------------------------------------------