From 820a1dc093b6c7e39e261cd1e492183101dbc0e7 Mon Sep 17 00:00:00 2001 From: Jacob Dufault Date: Fri, 7 Apr 2017 17:34:13 -0700 Subject: [PATCH] compile-fixes --- src/query.h | 6 +-- src/string.cc | 85 ---------------------------------- src/typed_bidi_message_queue.h | 4 +- 3 files changed, 4 insertions(+), 91 deletions(-) delete mode 100644 src/string.cc diff --git a/src/query.h b/src/query.h index a7915b95..47867489 100644 --- a/src/query.h +++ b/src/query.h @@ -30,7 +30,7 @@ struct IdMap; struct QueryableLocation { Usr path; Range range; - + QueryableLocation(Usr path, Range range) : path(path), range(range) {} @@ -100,8 +100,8 @@ struct ReplacementUpdate { // New entries. std::vector values; - ReplacementUpdate(Usr usr, const std::vector& entries) - : usr(usr), entries(entries) {} + ReplacementUpdate(Usr usr, const std::vector& values) + : usr(usr), values(values) {} }; struct QueryableFile { diff --git a/src/string.cc b/src/string.cc deleted file mode 100644 index d5c86b0f..00000000 --- a/src/string.cc +++ /dev/null @@ -1,85 +0,0 @@ -#include "buffer.h" - -#include -#include -#include -#include -#include -#include -#include - -struct CXString {}; // TODO - -struct StringView { - StringView(const char* str, size_t len); - - const char* const str; - size_t len; -}; - -struct StringDb { - StringView GetString(const std::string& str); - StringView GetString(const char* str); - StringView GetString(CXString cx_string); - - struct StringStorage { - ~StringStorage(); - - static StringStorage CreateUnowned(const char* data, size_t len); - void Copy(); - - const char* data; - size_t len; - bool owns_data; - }; - - std::unordered_set data_; -}; - -StringDb::StringStorage::~StringStorage() { - if (owns_data) { - free((void*)data); - data = nullptr; - owns_data = false; - } -} - -StringDb::StringStorage StringDb::StringStorage::CreateUnowned(const char* data, - size_t len) { - StringStorage result; - result.data = data; - result.len = len; - result.owns_data = false; - return result; -} - -void StringDb::StringStorage::Copy() { - // Copy - char* new_data = (char*)malloc(len + 1); - strncpy(new_data, data, len + 1); - // Assign - data = new_data; - owns_data = true; -} - -StringView::StringView(const char* str, size_t len) : str(str), len(len) {} - -StringView StringDb::GetString(const std::string& str) { - StringStorage lookup = StringStorage::CreateUnowned(str.c_str(), str.length()); - - auto it = data_.insert(str); - if (it.second) - it.first->Copy(); - - return StringView(it.first->c_str(), it.first->length()); -} - -StringView StringDb::GetString(CXString cx_string) { - assert(cx_string.data); - - StringView result string=clang_getCString(cx_string); - clang_disposeString(cx_string); - -} - - diff --git a/src/typed_bidi_message_queue.h b/src/typed_bidi_message_queue.h index 7ffcda23..cc524534 100644 --- a/src/typed_bidi_message_queue.h +++ b/src/typed_bidi_message_queue.h @@ -74,9 +74,7 @@ struct TypedBidiMessageQueue { document.Parse( reinterpret_cast(buffer->data) + sizeof(MessageHeader), buffer->capacity - sizeof(MessageHeader)); - bool has_error = document.HasParseError(); - auto error = document.GetParseError(); - if (has_error) { + if (document.HasParseError()) { std::cerr << "[FATAL]: Unable to parse IPC message" << std::endl; exit(1); }