summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-04-10 10:37:37 +0200
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-04-10 10:37:37 +0200
commit2d080a7fdfd2916e4723d19ba585a0f228118fb4 (patch)
tree1a4fbbe45dc6b83a44a1c827e13798dbcbcbe0fd
parent82ab3697a33e55591fe5b8c3c7fa8084424015f6 (diff)
argument names are probably always hard coded strings, so no reason to copy them to std::string objects, and now we also fix a memory corruption issue (issue #75)
-rw-r--r--include/argument.h22
-rw-r--r--zend/callable.h8
2 files changed, 15 insertions, 15 deletions
diff --git a/include/argument.h b/include/argument.h
index 81b1bf4..ddb6390 100644
--- a/include/argument.h
+++ b/include/argument.h
@@ -62,9 +62,9 @@ public:
/**
* Name of the argument
- * @return std::string
+ * @return const char *
*/
- const std::string &name() const
+ const char *name() const
{
return _name;
}
@@ -80,9 +80,9 @@ public:
/**
* If the type is a class, the name of the class
- * @return std::string
+ * @return const char *
*/
- const std::string &classname() const
+ const char *classname() const
{
return _classname;
}
@@ -108,39 +108,39 @@ public:
private:
/**
* Name of the argument
- * @var std::string
+ * @var const char *
*/
- std::string _name;
+ const char *_name = nullptr;
/**
* Type of argument
* @var Type
*/
- Type _type;
+ Type _type = Type::Null;
/**
* Classname, if this is a parameter that is supposed to be an instance of a class
* @var std::string
*/
- std::string _classname;
+ const char *_classname = nullptr;
/**
* May the parameter be null?
* @var bool
*/
- bool _nullable;
+ bool _nullable = false;
/**
* Is this a required argument
* @var bool
*/
- bool _required;
+ bool _required = true;
/**
* Is this a 'by-reference' parameter?
* @var bool
*/
- bool _byReference;
+ bool _byReference = false;
};
/**
diff --git a/zend/callable.h b/zend/callable.h
index 8f2fbef..9d7e69b 100644
--- a/zend/callable.h
+++ b/zend/callable.h
@@ -143,8 +143,8 @@ protected:
void fill(zend_arg_info *info, const Argument &arg) const
{
// fill members
- info->name = arg.name().c_str();
- info->name_len = arg.name().size();
+ info->name = arg.name();
+ info->name_len = ::strlen(arg.name());
#if PHP_VERSION_ID >= 50400
@@ -176,8 +176,8 @@ protected:
#endif
// this parameter is a regular type
- info->class_name = arg.type() == Type::Object ? arg.classname().c_str() : nullptr;
- info->class_name_len = arg.type() == Type::Object ? arg.classname().size() : 0;
+ info->class_name = arg.type() == Type::Object ? arg.classname() : nullptr;
+ info->class_name_len = arg.type() == Type::Object ? ::strlen(arg.classname()) : 0;
info->allow_null = arg.allowNull();
info->pass_by_reference = arg.byReference();
}