Coverage Report

Created: 2023-09-25 06:41

/src/xpdf-4.04/splash/SplashFontFile.cc
Line
Count
Source (jump to first uncovered line)
1
//========================================================================
2
//
3
// SplashFontFile.cc
4
//
5
// Copyright 2003-2013 Glyph & Cog, LLC
6
//
7
//========================================================================
8
9
#include <aconf.h>
10
11
#ifdef USE_GCC_PRAGMAS
12
#pragma implementation
13
#endif
14
15
#include <stdio.h>
16
#ifndef _WIN32
17
#  include <unistd.h>
18
#endif
19
#include "gmempp.h"
20
#include "GString.h"
21
#include "SplashFontFile.h"
22
#include "SplashFontFileID.h"
23
24
#ifdef VMS
25
#if (__VMS_VER < 70000000)
26
extern "C" int unlink(char *filename);
27
#endif
28
#endif
29
30
//------------------------------------------------------------------------
31
// SplashFontFile
32
//------------------------------------------------------------------------
33
34
SplashFontFile::SplashFontFile(SplashFontFileID *idA,
35
             SplashFontType fontTypeA,
36
#if LOAD_FONTS_FROM_MEM
37
             GString *fontBufA
38
#else
39
             char *fileNameA, GBool deleteFileA
40
#endif
41
0
             ) {
42
0
  id = idA;
43
0
  fontType = fontTypeA;
44
#if LOAD_FONTS_FROM_MEM
45
  fontBuf = fontBufA;
46
#else
47
0
  fileName = new GString(fileNameA);
48
0
  deleteFile = deleteFileA;
49
0
#endif
50
0
  refCnt = 0;
51
0
}
52
53
0
SplashFontFile::~SplashFontFile() {
54
#if LOAD_FONTS_FROM_MEM
55
  delete fontBuf;
56
#else
57
0
  if (deleteFile) {
58
0
    unlink(fileName->getCString());
59
0
  }
60
0
  delete fileName;
61
0
#endif
62
0
  delete id;
63
0
}
64
65
0
void SplashFontFile::incRefCnt() {
66
0
#if MULTITHREADED
67
0
  gAtomicIncrement(&refCnt);
68
#else
69
  ++refCnt;
70
#endif
71
0
}
72
73
0
void SplashFontFile::decRefCnt() {
74
0
  GBool done;
75
76
0
#if MULTITHREADED
77
0
  done = gAtomicDecrement(&refCnt) == 0;
78
#else
79
  done = --refCnt == 0;
80
#endif
81
0
  if (done) {
82
0
    delete this;
83
0
  }
84
0
}