Coverage Report

Created: 2022-01-18 06:27

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Host/macosx/cfcpp/CFCData.cpp
Line
Count
Source (jump to first uncovered line)
1
//===-- CFCData.cpp -------------------------------------------------------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#include "CFCData.h"
10
11
// CFCData constructor
12
6
CFCData::CFCData(CFDataRef data) : CFCReleaser<CFDataRef>(data) {}
13
14
// CFCData copy constructor
15
0
CFCData::CFCData(const CFCData &rhs) : CFCReleaser<CFDataRef>(rhs) {}
16
17
// CFCData copy constructor
18
CFCData &CFCData::operator=(const CFCData &rhs)
19
20
0
{
21
0
  if (this != &rhs)
22
0
    *this = rhs;
23
0
  return *this;
24
0
}
25
26
// Destructor
27
6
CFCData::~CFCData() = default;
28
29
0
CFIndex CFCData::GetLength() const {
30
0
  CFDataRef data = get();
31
0
  if (data)
32
0
    return CFDataGetLength(data);
33
0
  return 0;
34
0
}
35
36
0
const uint8_t *CFCData::GetBytePtr() const {
37
0
  CFDataRef data = get();
38
0
  if (data)
39
0
    return CFDataGetBytePtr(data);
40
0
  return NULL;
41
0
}
42
43
CFDataRef CFCData::Serialize(CFPropertyListRef plist,
44
0
                             CFPropertyListFormat format) {
45
0
  CFAllocatorRef alloc = kCFAllocatorDefault;
46
0
  reset();
47
0
  CFCReleaser<CFWriteStreamRef> stream(
48
0
      ::CFWriteStreamCreateWithAllocatedBuffers(alloc, alloc));
49
0
  ::CFWriteStreamOpen(stream.get());
50
0
  CFIndex len =
51
0
      ::CFPropertyListWriteToStream(plist, stream.get(), format, NULL);
52
0
  if (len > 0)
53
0
    reset((CFDataRef)::CFWriteStreamCopyProperty(stream.get(),
54
0
                                                 kCFStreamPropertyDataWritten));
55
0
  ::CFWriteStreamClose(stream.get());
56
0
  return get();
57
0
}