]> git.ipfire.org Git - thirdparty/cups.git/blob - ppdc/ppdc-string.cxx
Merge pull request #5621 from zdohnal/cgigetarray-sigsegv
[thirdparty/cups.git] / ppdc / ppdc-string.cxx
1 //
2 // Shared string class for the CUPS PPD Compiler.
3 //
4 // Copyright 2007-2012 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 // 'ppdcString::ppdcString()' - Create a shared string.
19 //
20
21 ppdcString::ppdcString(const char *v) // I - String
22 : ppdcShared()
23 {
24 PPDC_NEWVAL(v);
25
26 if (v)
27 {
28 size_t vlen = strlen(v);
29
30 value = new char[vlen + 1];
31 memcpy(value, v, vlen + 1);
32 }
33 else
34 value = 0;
35 }
36
37
38 //
39 // 'ppdcString::~ppdcString()' - Destroy a shared string.
40 //
41
42 ppdcString::~ppdcString()
43 {
44 PPDC_DELETEVAL(value);
45
46 if (value)
47 delete[] value;
48 }