1//
2// "$Id: ppdc-shared.cxx 1558 2009-06-10 19:21:50Z msweet $"
3//
4//   Shared data class for the CUPS PPD Compiler.
5//
6//   Copyright 2007-2009 by Apple Inc.
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.
19//   ppdcShared::release()     - Decrement the use count and delete as needed.
20//   ppdcShared::retain()      - Increment the use count for this data.
21//
22
23//
24// Include necessary headers...
25//
26
27#include "ppdc-private.h"
28
29
30//
31// 'ppdcShared::ppdcShared()' - Create shared data.
32//
33
34ppdcShared::ppdcShared()
35{
36  use = 1;
37}
38
39
40//
41// 'ppdcShared::~ppdcShared()' - Destroy shared data.
42//
43
44ppdcShared::~ppdcShared()
45{
46}
47
48
49//
50// 'ppdcShared::release()' - Decrement the use count and delete as needed.
51//
52
53void
54ppdcShared::release(void)
55{
56  DEBUG_printf(("%s: %p release use=%d", class_name(), this, use));
57
58  use --;
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)
69    delete this;
70}
71
72
73//
74// 'ppdcShared::retain()' - Increment the use count for this data.
75//
76
77void
78ppdcShared::retain()
79{
80  use ++;
81
82  DEBUG_printf(("%s: %p retain use=%d", class_name(), this, use));
83}
84
85
86//
87// End of "$Id: ppdc-shared.cxx 1558 2009-06-10 19:21:50Z msweet $".
88//
89