Synopsis - Cross-Reference

File: src/Synopsis/PTree/Atoms.cc
 1//
 2// Copyright (C) 1997-2000 Shigeru Chiba
 3// Copyright (C) 2004 Stefan Seefeld
 4// All rights reserved.
 5// Licensed to the public under the terms of the GNU LGPL (>= 2),
 6// see the file COPYING for details.
 7//
 8#include "Synopsis/PTree/Atoms.hh"
 9
10using namespace Synopsis;
11using namespace PTree;
12
13namespace
14{
15// little helper for initialization
16char *dup_alloc(const char *str1, size_t len1,
17		const char *str2, size_t len2)
18{
19  char *buffer = new (GC) char[len1 + len2];
20  memmove(buffer, str1, len1);
21  memmove(buffer + len1, str2, len2);
22  return buffer;
23}
24
25}
26
27using namespace PTree;
28
29DupAtom::DupAtom(const char *str, size_t len)
30  : CommentedAtom(static_cast<char *>(memmove(new (GC) char[len], str, len)), len)
31{
32}
33
34DupAtom::DupAtom(const char *str1, size_t len1,
35		 const char *str2, size_t len2)
36  : CommentedAtom(dup_alloc(str1, len1, str2, len2), len1 + len2)
37{
38}
39