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.
This commit is contained in:
@@ -215,7 +215,7 @@ parse_path (const string &path, vector<PathComponent> &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];
|
||||
}
|
||||
|
||||
@@ -1081,7 +1081,7 @@ private:
|
||||
|
||||
class hash_table;
|
||||
|
||||
const char * _name;
|
||||
char * _name;
|
||||
int _index;
|
||||
SGPropertyNode * _parent;
|
||||
vector<SGPropertyNode *> _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);
|
||||
|
||||
Reference in New Issue
Block a user