diff options
Diffstat (limited to 'src/lib/main.c')
| -rw-r--r-- | src/lib/main.c | 41 |
1 files changed, 11 insertions, 30 deletions
diff --git a/src/lib/main.c b/src/lib/main.c index 2bd374b..81cd6bb 100644 --- a/src/lib/main.c +++ b/src/lib/main.c @@ -19,8 +19,7 @@ aplwc_new(struct aplwc **p, uint8_t *data, size_t size) void aplwc_destroy(struct aplwc *p) { - if(p) - memory_free_aplwc(p, p); + UNUSED_PARAMETER(p); } const char * @@ -97,9 +96,8 @@ aplwc_read(struct aplwc *aplwc, const char *line) void aplwc_free_line(struct aplwc_line *line) { - if(line == NULL) - return; - memory_free_aplwc_line(line->aplwc, line); + if(line) + memory_free_root(line->aplwc, line); } struct aplwc_value * @@ -112,9 +110,8 @@ aplwc_eval(struct aplwc_line *line) void aplwc_free_value(struct aplwc_value *value) { - if(value == NULL) - return; - memory_free_aplwc_value(value->aplwc, value); + if(value) + memory_free_root(value->aplwc, value); } const char * @@ -134,32 +131,16 @@ aplwc_load_module(struct aplwc *aplwc, const char *name, const char *src, int sr struct string *text, *namestr; struct token_list *tokens; - namestr = NULL; - text = NULL; - tokens = NULL; - - namestr = chars_to_string(aplwc, name, -1); - if(namestr == NULL) + if((namestr = chars_to_string(aplwc, name, -1)) == NULL) goto error; - - text = chars_to_string(aplwc, src, srclen); - if(text == NULL) + if((text = chars_to_string(aplwc, src, srclen)) == NULL) goto error; - - tokens = scan_string(aplwc, text, 0); - if(tokens == NULL) + if((tokens = scan_string(aplwc, text, 0)) == NULL) goto error; - - if(load_module(aplwc, namestr, tokens) == APLWC_OK) - return APLWC_OK; - else{ + if(load_module(aplwc, namestr, tokens) != APLWC_OK){ error: - if(tokens != NULL) - memory_free_token_list(aplwc, tokens); - if(text != NULL) - memory_free_string(aplwc, text); - if(namestr != NULL) - memory_free_string(aplwc, namestr); return aplwc_last_error(aplwc); } + + return APLWC_OK; } |