• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Shared data class for the CUPS PPD Compiler.
3 //
4 // Copyright © 2020-2024 by OpenPrinting.
5 // Copyright 2007-2009 by Apple Inc.
6 // Copyright 2002-2005 by Easy Software Products.
7 //
8 // Licensed under Apache License v2.0.  See the file "LICENSE" for more information.
9 //
10 
11 //
12 // Include necessary headers...
13 //
14 
15 #include "ppdc-private.h"
16 
17 
18 //
19 // 'ppdcShared::ppdcShared()' - Create shared data.
20 //
21 
ppdcShared()22 ppdcShared::ppdcShared()
23 {
24   use = 1;
25 }
26 
27 
28 //
29 // 'ppdcShared::~ppdcShared()' - Destroy shared data.
30 //
31 
~ppdcShared()32 ppdcShared::~ppdcShared()
33 {
34 }
35 
36 
37 //
38 // 'ppdcShared::release()' - Decrement the use count and delete as needed.
39 //
40 
41 void
release(void)42 ppdcShared::release(void)
43 {
44   use --;
45 
46 #ifdef DEBUG
47   if (use < 0)
48   {
49     fprintf(stderr, "ERROR: Over-release of %s: %p\n", class_name(), this);
50     abort();
51   }
52 #endif /* DEBUG */
53 
54   if (use == 0)
55     delete this;
56 }
57 
58 
59 //
60 // 'ppdcShared::retain()' - Increment the use count for this data.
61 //
62 
63 void
retain()64 ppdcShared::retain()
65 {
66   use ++;
67 }
68