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