forked from OctaForge/libcubescript
cleanups
parent
52eb44e0bc
commit
b687bd6016
|
@ -8,7 +8,14 @@
|
|||
|
||||
namespace cscript {
|
||||
|
||||
char *cs_dup_ostr(ostd::ConstCharRange s);
|
||||
char *cs_dup_ostr(ostd::ConstCharRange s) {
|
||||
char *r = new char[s.size() + 1];
|
||||
if (s.data()) {
|
||||
memcpy(r, s.data(), s.size());
|
||||
}
|
||||
r[s.size()] = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
static char const *parsestring(char const *p) {
|
||||
while (*p) {
|
||||
|
|
|
@ -16,15 +16,6 @@ CsString floatstr(CsFloat v) {
|
|||
return static_cast<char const *>(buf);
|
||||
}
|
||||
|
||||
char *cs_dup_ostr(ostd::ConstCharRange s) {
|
||||
char *r = new char[s.size() + 1];
|
||||
if (s.data()) {
|
||||
memcpy(r, s.data(), s.size());
|
||||
}
|
||||
r[s.size()] = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
bool cs_check_num(ostd::ConstCharRange s) {
|
||||
if (isdigit(s[0])) {
|
||||
return true;
|
||||
|
@ -101,7 +92,7 @@ CsCommand::CsCommand(
|
|||
int nargs, CsCommandCb f
|
||||
):
|
||||
CsIdent(CsIdentType::command, name, 0),
|
||||
p_cargs(cs_dup_ostr(args)), p_numargs(nargs), p_cb_cftv(ostd::move(f))
|
||||
p_cargs(args), p_cb_cftv(ostd::move(f)), p_numargs(nargs)
|
||||
{}
|
||||
|
||||
bool CsIdent::is_alias() const {
|
||||
|
@ -353,8 +344,6 @@ CsState::~CsState() {
|
|||
if (a) {
|
||||
a->get_value().force_null();
|
||||
a->clean_code();
|
||||
} else if (i->is_command() || i->is_special()) {
|
||||
delete[] static_cast<CsCommand *>(i)->p_cargs;
|
||||
}
|
||||
delete i;
|
||||
}
|
||||
|
|
|
@ -314,9 +314,9 @@ private:
|
|||
int numargs, CsCommandCb func
|
||||
);
|
||||
|
||||
char *p_cargs;
|
||||
int p_numargs;
|
||||
CsString p_cargs;
|
||||
CsCommandCb p_cb_cftv;
|
||||
int p_numargs;
|
||||
};
|
||||
|
||||
struct CsIdentLink {
|
||||
|
|
Loading…
Reference in New Issue