From 1bc333972bb5d5b45ba8908f1b12015300d88711 Mon Sep 17 00:00:00 2001 From: Jonathan Beck Date: Wed, 28 Oct 2009 17:57:52 +0100 Subject: Fix build for MSVC9. --- src/Array.cpp | 5 +++-- src/Boolean.cpp | 3 ++- src/Data.cpp | 1 + src/Date.cpp | 1 + src/Dictionary.cpp | 1 + src/Integer.cpp | 1 + src/Node.cpp | 3 ++- src/Real.cpp | 1 + src/String.cpp | 1 + src/bplist.c | 2 +- src/plist.c | 11 +++++++---- src/plist.h | 5 +++++ 12 files changed, 26 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/Array.cpp b/src/Array.cpp index 7c8272c..dbb1239 100644 --- a/src/Array.cpp +++ b/src/Array.cpp @@ -58,7 +58,7 @@ Array::Array(PList::Array& a) : Structure() Array& Array::operator=(PList::Array& a) { plist_free(_node); - for (int it = 0; it < _array.size(); it++) + for (unsigned int it = 0; it < _array.size(); it++) { delete _array.at(it); } @@ -72,11 +72,12 @@ Array& Array::operator=(PList::Array& a) plist_t subnode = plist_array_get_item(_node, i); _array.push_back( Utils::FromPlist(subnode, this) ); } + return *this; } Array::~Array() { - for (int it = 0; it < _array.size(); it++) + for (unsigned int it = 0; it < _array.size(); it++) { delete (_array.at(it)); } diff --git a/src/Boolean.cpp b/src/Boolean.cpp index 3b20f45..dfa96ca 100644 --- a/src/Boolean.cpp +++ b/src/Boolean.cpp @@ -41,6 +41,7 @@ Boolean& Boolean::operator=(PList::Boolean& b) { plist_free(_node); _node = plist_copy(b.GetPlist()); + return *this; } Boolean::Boolean(bool b) : Node(PLIST_BOOLEAN) @@ -66,7 +67,7 @@ bool Boolean::GetValue() { uint8_t b = 0; plist_get_bool_val(_node, &b); - return b; + return b != 0 ; } }; diff --git a/src/Data.cpp b/src/Data.cpp index a171c03..02ce983 100644 --- a/src/Data.cpp +++ b/src/Data.cpp @@ -42,6 +42,7 @@ Data& Data::operator=(PList::Data& b) { plist_free(_node); _node = plist_copy(b.GetPlist()); + return *this; } Data::Data(const std::vector& buff) : Node(PLIST_DATA) diff --git a/src/Date.cpp b/src/Date.cpp index 6321c84..cb817d9 100644 --- a/src/Date.cpp +++ b/src/Date.cpp @@ -42,6 +42,7 @@ Date& Date::operator=(PList::Date& d) { plist_free(_node); _node = plist_copy(d.GetPlist()); + return *this; } Date::Date(timeval t) : Node(PLIST_DATE) diff --git a/src/Dictionary.cpp b/src/Dictionary.cpp index 2c56c89..72307f1 100644 --- a/src/Dictionary.cpp +++ b/src/Dictionary.cpp @@ -104,6 +104,7 @@ Dictionary& Dictionary::operator=(PList::Dictionary& d) plist_dict_next_item(_node, it, NULL, &subnode); } free(it); + return *this; } Dictionary::~Dictionary() diff --git a/src/Integer.cpp b/src/Integer.cpp index 9cf6619..4c8a825 100644 --- a/src/Integer.cpp +++ b/src/Integer.cpp @@ -41,6 +41,7 @@ Integer& Integer::operator=(PList::Integer& i) { plist_free(_node); _node = plist_copy(i.GetPlist()); + return *this; } Integer::Integer(uint64_t i) : Node(PLIST_UINT) diff --git a/src/Node.cpp b/src/Node.cpp index 4497bb1..e513862 100644 --- a/src/Node.cpp +++ b/src/Node.cpp @@ -79,8 +79,9 @@ plist_type Node::GetType() { if (_node) { - return plist_get_node_type(_node); + return plist_get_node_type(_node); } + return PLIST_NONE; } plist_t Node::GetPlist() diff --git a/src/Real.cpp b/src/Real.cpp index a877b40..512c44e 100644 --- a/src/Real.cpp +++ b/src/Real.cpp @@ -41,6 +41,7 @@ Real& Real::operator=(PList::Real& d) { plist_free(_node); _node = plist_copy(d.GetPlist()); + return *this; } Real::Real(double d) : Node(PLIST_REAL) diff --git a/src/String.cpp b/src/String.cpp index e6cceaa..3ae158e 100644 --- a/src/String.cpp +++ b/src/String.cpp @@ -41,6 +41,7 @@ String& String::operator=(PList::String& s) { plist_free(_node); _node = plist_copy(s.GetPlist()); + return *this; } String::String(const std::string& s) : Node(PLIST_STRING) diff --git a/src/bplist.c b/src/bplist.c index cd7fe9b..6e3007a 100644 --- a/src/bplist.c +++ b/src/bplist.c @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include "plist.h" diff --git a/src/plist.c b/src/plist.c index 95b9593..30be007 100644 --- a/src/plist.c +++ b/src/plist.c @@ -64,8 +64,9 @@ static void plist_free_data(plist_data_t data) static void plist_free_node(GNode * node, gpointer none) { + plist_data_t data = NULL; g_node_unlink(node); - plist_data_t data = plist_get_data(node); + data = plist_get_data(node); plist_free_data(data); node->data = NULL; g_node_children_foreach(node, G_TRAVERSE_ALL, plist_free_node, NULL); @@ -161,6 +162,7 @@ void plist_free(plist_t plist) static void plist_copy_node(GNode * node, gpointer parent_node_ptr) { + plist_type node_type = PLIST_NONE; plist_t newnode = NULL; plist_data_t data = plist_get_data(node); plist_data_t newdata = plist_new_plist_data(); @@ -169,7 +171,7 @@ static void plist_copy_node(GNode * node, gpointer parent_node_ptr) memcpy(newdata, data, sizeof(struct plist_data_s)); - plist_type node_type = plist_get_node_type(node); + node_type = plist_get_node_type(node); if (node_type == PLIST_DATA || node_type == PLIST_STRING || node_type == PLIST_KEY) { switch (node_type) { case PLIST_DATA: @@ -225,6 +227,7 @@ uint32_t plist_array_get_item_index(plist_t node) if (PLIST_ARRAY == plist_get_node_type(father)) { return g_node_child_position(father, node); } + return 0; } void plist_array_set_item(plist_t node, plist_t item, uint32_t n) @@ -330,8 +333,8 @@ plist_t plist_dict_get_item(plist_t node, const char* key) current; current = (plist_t)g_node_next_sibling(g_node_next_sibling(current))) { - assert( PLIST_KEY == plist_get_node_type(current) ); plist_data_t data = plist_get_data(current); + assert( PLIST_KEY == plist_get_node_type(current) ); if (data && !strcmp(key, data->strval)) { ret = (plist_t)g_node_next_sibling(current); @@ -623,7 +626,7 @@ char plist_compare_node_value(plist_t node_l, plist_t node_r) return plist_data_compare(node_l, node_r); } -static plist_t plist_set_element_val(plist_t node, plist_type type, const void *value, uint64_t length) +static void plist_set_element_val(plist_t node, plist_type type, const void *value, uint64_t length) { //free previous allocated buffer plist_data_t data = plist_get_data(node); diff --git a/src/plist.h b/src/plist.h index 723ed87..b642d74 100644 --- a/src/plist.h +++ b/src/plist.h @@ -29,6 +29,11 @@ #include #include +#ifdef _MSC_VER +#pragma warning(disable:4996) +#pragma warning(disable:4244) +#endif + struct plist_data_s { union { -- cgit v1.1-32-gdbae