1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
4 // Copyright (c) 2011, 2013 Google Inc.
5 // All rights reserved.
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions are
11 // * Redistributions of source code must retain the above copyright
12 // notice, this list of conditions and the following disclaimer.
13 // * Redistributions in binary form must reproduce the above
14 // copyright notice, this list of conditions and the following disclaimer
15 // in the documentation and/or other materials provided with the
17 // * Neither the name of Google Inc. nor the names of its
18 // contributors may be used to endorse or promote products derived from
19 // this software without specific prior written permission.
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 // Original author: Jim Blandy <jimb@mozilla.com> <jimb@red-bean.com>
35 // This file is derived from the following files in
36 // toolkit/crashreporter/google-breakpad:
37 // src/common/module.cc
38 // src/common/unique_string.cc
40 // There's no internal-only interface for LulCommon. Hence include
41 // the external interface directly.
42 #include "LulCommonExt.h"
50 #include "BaseProfiler.h"
56 ////////////////////////////////////////////////////////////////
59 Module::Module(const string
& name
, const string
& os
, const string
& architecture
,
61 : name_(name
), os_(os
), architecture_(architecture
), id_(id
) {}
65 ////////////////////////////////////////////////////////////////
70 explicit UniqueString(string str
) { str_
= strdup(str
.c_str()); }
71 ~UniqueString() { free(reinterpret_cast<void*>(const_cast<char*>(str_
))); }
75 const char* FromUniqueString(const UniqueString
* ustr
) { return ustr
->str_
; }
77 bool IsEmptyUniqueString(const UniqueString
* ustr
) {
78 return (ustr
->str_
)[0] == '\0';
81 ////////////////////////////////////////////////////////////////
82 // UniqueStringUniverse
84 UniqueStringUniverse::~UniqueStringUniverse() {
85 for (std::map
<string
, UniqueString
*>::iterator it
= map_
.begin();
86 it
!= map_
.end(); it
++) {
91 const UniqueString
* UniqueStringUniverse::ToUniqueString(string str
) {
92 std::map
<string
, UniqueString
*>::iterator it
= map_
.find(str
);
93 if (it
== map_
.end()) {
94 UniqueString
* ustr
= new UniqueString(str
);