Use const variables in eval as much as possible.

This commit is contained in:
2017-07-20 22:09:42 -07:00
parent 6d520028b4
commit 600f169b5b
2 changed files with 9 additions and 9 deletions

View File

@@ -25,7 +25,7 @@ struct eval_s {
/**
* The input being evaluated.
*/
char* string;
const char* string;
/**
* The current index in the input.
*/
@@ -96,7 +96,7 @@ liblex_result eval_config_free(eval_config* config);
* @param pattern_id the id to associate with the pattern
* @return LIBLEX_SUCCESS if all goes well, or LIBLEX_MALLOC if there was an allocation failure.
*/
liblex_result eval_config_add(eval_config* config, char* pattern, int pattern_id);
liblex_result eval_config_add(eval_config* config, const char* pattern, int pattern_id);
/**
* Evaluates / finds a single word.
* @param string the string to evaluate.
@@ -105,7 +105,7 @@ liblex_result eval_config_add(eval_config* config, char* pattern, int pattern_id
* @param match pointer to where to store the newly created match.
* @return LIBLEX_SUCCESS if all goes well, or LIBLEX_MALLOC if there was an allocation failure.
*/
liblex_result eval_word(char* string, size_t index, eval_config* config, match* match);
liblex_result eval_word(const char* string, size_t index, eval_config* config, match* match);
/**
* Evaluates input starting at the index until it reaches the null terminator,
* adding the best matches to the linked list.
@@ -115,7 +115,7 @@ liblex_result eval_word(char* string, size_t index, eval_config* config, match*
* @param matches the linked list to populate with matches
* @return LIBLEX_SUCCESS if all goes well, or LIBLEX_MALLOC if there was an allocation failure.
*/
liblex_result eval_all(char* string, size_t index, eval_config* config, ll* matches);
liblex_result eval_all(const char* string, size_t index, eval_config* config, ll* matches);
/**
* Function intended to be passed to "foreach" calls in libds.
* Since eval_all creates a lot of matches and puts them all in a linked list,