From: david Date: Sun, 7 Apr 2002 21:28:43 +0000 (+0000) Subject: Patch from Frederic Bouvier: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;ds=sidebyside;h=711622fd5bff3f042116023e0c1be61d22ef8f4c;p=simgear.git Patch from Frederic Bouvier: A const char * is not supposed to change and cannot be deleted. So here is a patch that remove unnecessary const from props.hxx and props.cxx. There also is the addition of a friend directive because nested classes do not receive special privileges and cannot access private members of the outer class. --- diff --git a/simgear/misc/props.cxx b/simgear/misc/props.cxx index af2044a4..19cb3a98 100644 --- a/simgear/misc/props.cxx +++ b/simgear/misc/props.cxx @@ -215,7 +215,7 @@ parse_path (const string &path, vector &components) //////////////////////////////////////////////////////////////////////// -static const char * +static char * copy_string (const char * s) { // FIXME: potential buffer overflow. @@ -417,7 +417,7 @@ SGPropertyNode::set_string (const char * val) if (_tied) { return _value.string_val->setValue(val); } else { - delete [] (char *)_local_val.string_val; + delete [] _local_val.string_val; _local_val.string_val = copy_string(val); return true; } @@ -473,7 +473,7 @@ SGPropertyNode::clear_value () delete _value.string_val; _value.string_val = 0; } else { - delete [] (char *)_local_val.string_val; + delete [] _local_val.string_val; } _local_val.string_val = 0; break; @@ -675,7 +675,7 @@ SGPropertyNode::SGPropertyNode (const char * name, */ SGPropertyNode::~SGPropertyNode () { - delete [] (char *)_name; + delete [] _name; for (int i = 0; i < (int)_children.size(); i++) { delete _children[i]; } diff --git a/simgear/misc/props.hxx b/simgear/misc/props.hxx index 1be0c093..a5e8528b 100644 --- a/simgear/misc/props.hxx +++ b/simgear/misc/props.hxx @@ -1081,7 +1081,7 @@ private: class hash_table; - const char * _name; + char * _name; int _index; SGPropertyNode * _parent; vector _children; @@ -1107,7 +1107,7 @@ private: long long_val; float float_val; double double_val; - const char * string_val; + char * string_val; } _local_val; @@ -1130,7 +1130,7 @@ private: virtual SGPropertyNode * get_value () { return _value; } virtual void set_value (SGPropertyNode * value); private: - const char * _key; + char * _key; SGPropertyNode * _value; }; @@ -1148,6 +1148,8 @@ private: entry ** _entries; }; + friend class bucket; + hash_table (); virtual ~hash_table (); virtual SGPropertyNode * get (const char * key);