• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Shared string class for the CUPS PPD Compiler.
3 //
4 // Copyright © 2020-2024 by OpenPrinting.
5 // Copyright 2007-2012 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 // 'ppdcString::ppdcString()' - Create a shared string.
20 //
21 
ppdcString(const char * v)22 ppdcString::ppdcString(const char *v)	// I - String
23   : ppdcShared()
24 {
25   PPDC_NEWVAL(v);
26 
27   if (v)
28   {
29     size_t vlen = strlen(v);
30 
31     value = new char[vlen + 1];
32     memcpy(value, v, vlen + 1);
33   }
34   else
35     value = 0;
36 }
37 
38 
39 //
40 // 'ppdcString::~ppdcString()' - Destroy a shared string.
41 //
42 
~ppdcString()43 ppdcString::~ppdcString()
44 {
45   PPDC_DELETEVAL(value);
46 
47   if (value)
48     delete[] value;
49 }
50