]>
Commit | Line | Data |
---|---|---|
ac884b6a MS |
1 | // |
2 | // "$Id$" | |
3 | // | |
4 | // Shared data class for the CUPS PPD Compiler. | |
5 | // | |
94da7e34 | 6 | // Copyright 2007-2009 by Apple Inc. |
ac884b6a MS |
7 | // Copyright 2002-2005 by Easy Software Products. |
8 | // | |
9 | // These coded instructions, statements, and computer programs are the | |
10 | // property of Apple Inc. and are protected by Federal copyright | |
11 | // law. Distribution and use rights are outlined in the file "LICENSE.txt" | |
12 | // which should have been included with this file. If this file is | |
13 | // file is missing or damaged, see the license at "http://www.cups.org/". | |
14 | // | |
15 | // Contents: | |
16 | // | |
17 | // ppdcShared::ppdcShared() - Create shared data. | |
18 | // ppdcShared::~ppdcShared() - Destroy shared data. | |
ac884b6a | 19 | // ppdcShared::release() - Decrement the use count and delete as needed. |
e4572d57 | 20 | // ppdcShared::retain() - Increment the use count for this data. |
ac884b6a MS |
21 | // |
22 | ||
23 | // | |
24 | // Include necessary headers... | |
25 | // | |
26 | ||
38e73f87 | 27 | #include "ppdc-private.h" |
ac884b6a MS |
28 | |
29 | ||
30 | // | |
31 | // 'ppdcShared::ppdcShared()' - Create shared data. | |
32 | // | |
33 | ||
34 | ppdcShared::ppdcShared() | |
35 | { | |
36 | use = 1; | |
37 | } | |
38 | ||
39 | ||
40 | // | |
41 | // 'ppdcShared::~ppdcShared()' - Destroy shared data. | |
42 | // | |
43 | ||
44 | ppdcShared::~ppdcShared() | |
45 | { | |
46 | } | |
47 | ||
48 | ||
49 | // | |
e4572d57 | 50 | // 'ppdcShared::release()' - Decrement the use count and delete as needed. |
ac884b6a MS |
51 | // |
52 | ||
53 | void | |
e4572d57 | 54 | ppdcShared::release(void) |
ac884b6a | 55 | { |
38e73f87 | 56 | DEBUG_printf(("%s: %p release use=%d", class_name(), this, use)); |
94da7e34 | 57 | |
e4572d57 | 58 | use --; |
97c9a8d7 MS |
59 | |
60 | #ifdef DEBUG | |
61 | if (use < 0) | |
62 | { | |
63 | fprintf(stderr, "ERROR: Over-release of %s: %p\n", class_name(), this); | |
64 | abort(); | |
65 | } | |
66 | #endif /* DEBUG */ | |
67 | ||
68 | if (use == 0) | |
e4572d57 | 69 | delete this; |
ac884b6a MS |
70 | } |
71 | ||
72 | ||
73 | // | |
e4572d57 | 74 | // 'ppdcShared::retain()' - Increment the use count for this data. |
ac884b6a MS |
75 | // |
76 | ||
77 | void | |
e4572d57 | 78 | ppdcShared::retain() |
ac884b6a | 79 | { |
e4572d57 | 80 | use ++; |
94da7e34 | 81 | |
38e73f87 | 82 | DEBUG_printf(("%s: %p retain use=%d", class_name(), this, use)); |
ac884b6a MS |
83 | } |
84 | ||
85 | ||
86 | // | |
87 | // End of "$Id$". | |
88 | // |