There is the ability to change the number of allowed functions and variables, which is great.
However, I only discovered it after pulling my hair out for a day with crashing code.
Bottom line the functions and variables routine does NOT error check that the defined arrays are kept within bounds. So if the defined limit was 5 functions but I made a sixth or tenth call to rest.functions(...) it merrily writes over memory leading to random fails.
In my local version I made both of those functions return an int, so I could indicate that the call failed. Then added safety checks before assigning the new values into the arrays and if the arrays are already full I just return an error condition (-1). See code snippet below
Would be happy to add to the primary release of of interest.
Rob
template
int variable(const char name, T var, bool quotable) {
if (variables_index >= NUMBER_VARIABLES)
return(-1);
variables[variables_index] = new TypedVariable(var, quotable);
variable_names[variables_index] = name;
variables_index++;
return(0);
}
template
int variable(const char name, T var) {
return(variable(name, var, true));
}
There is the ability to change the number of allowed functions and variables, which is great.
However, I only discovered it after pulling my hair out for a day with crashing code.
Bottom line the functions and variables routine does NOT error check that the defined arrays are kept within bounds. So if the defined limit was 5 functions but I made a sixth or tenth call to rest.functions(...) it merrily writes over memory leading to random fails.
In my local version I made both of those functions return an int, so I could indicate that the call failed. Then added safety checks before assigning the new values into the arrays and if the arrays are already full I just return an error condition (-1). See code snippet below
Would be happy to add to the primary release of of interest.
Rob
template
int variable(const char name, T var, bool quotable) {
if (variables_index >= NUMBER_VARIABLES)
return(-1);
variables[variables_index] = new TypedVariable(var, quotable);
variable_names[variables_index] = name;
variables_index++;
return(0);
}
template
int variable(const char name, T var) {
return(variable(name, var, true));
}