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