Make foreach_free public and fix a few bugs.

This commit is contained in:
2017-02-14 19:10:44 -08:00
parent 97933c4ce9
commit 140b727cc7
3 changed files with 38 additions and 15 deletions

View File

@@ -115,5 +115,14 @@ liblex_result eval_word(char* string, int index, eval_config* config, match* mat
* @return LIBLEX_SUCCESS if all goes well, or LIBLEX_MALLOC if there was an allocation failure.
*/
liblex_result eval_all(char* string, int 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,
* this function takes care of freeing the matches.
* @param data the match being freed
* @param args unused
* @return always 0.
*/
int eval_foreach_match_free(void *data, va_list args);
#endif

View File

@@ -16,7 +16,11 @@ enum liblex_result_e {
/**
* Represents an invalid pattern.
*/
LIBLEX_INVALID
LIBLEX_INVALID,
/**
* Represents an unrecognized token.
*/
LIBLEX_UNRECOGNIZED
};
typedef enum liblex_result_e liblex_result;