diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/wee-eval.c | 41 | ||||
-rw-r--r-- | src/core/wee-eval.h | 1 | ||||
-rw-r--r-- | src/core/weechat.c | 1 |
3 files changed, 13 insertions, 30 deletions
diff --git a/src/core/wee-eval.c b/src/core/wee-eval.c index 01243c198..23af934de 100644 --- a/src/core/wee-eval.c +++ b/src/core/wee-eval.c @@ -780,7 +780,7 @@ char * eval_expression (const char *expr, struct t_hashtable *pointers, struct t_hashtable *extra_vars, struct t_hashtable *options) { - int condition, rc; + int condition, rc, pointers_allocated; char *value; const char *prefix, *suffix, *default_prefix = "${", *default_suffix = "}"; const char *ptr_value; @@ -790,25 +790,21 @@ eval_expression (const char *expr, struct t_hashtable *pointers, return NULL; condition = 0; + pointers_allocated = 0; prefix = default_prefix; suffix = default_suffix; /* create hashtable pointers if it's NULL */ if (!pointers) { - if (eval_hashtable_pointers) - hashtable_remove_all (eval_hashtable_pointers); - else - { - eval_hashtable_pointers = hashtable_new (32, - WEECHAT_HASHTABLE_STRING, - WEECHAT_HASHTABLE_POINTER, - NULL, - NULL); - if (!eval_hashtable_pointers) - return NULL; - } - pointers = eval_hashtable_pointers; + pointers = hashtable_new (32, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_POINTER, + NULL, + NULL); + if (!pointers) + return NULL; + pointers_allocated = 1; } /* @@ -863,19 +859,8 @@ eval_expression (const char *expr, struct t_hashtable *pointers, value = eval_replace_vars (expr, pointers, extra_vars, prefix, suffix); } - return value; -} - -/* - * Frees all allocated data. - */ + if (pointers_allocated) + hashtable_free (pointers); -void -eval_end () -{ - if (eval_hashtable_pointers) - { - hashtable_free (eval_hashtable_pointers); - eval_hashtable_pointers = NULL; - } + return value; } diff --git a/src/core/wee-eval.h b/src/core/wee-eval.h index 652cd0b91..7af69c265 100644 --- a/src/core/wee-eval.h +++ b/src/core/wee-eval.h @@ -52,6 +52,5 @@ extern char *eval_expression (const char *expr, struct t_hashtable *pointers, struct t_hashtable *extra_vars, struct t_hashtable *options); -extern void eval_end (); #endif /* __WEECHAT_EVAL_H */ diff --git a/src/core/weechat.c b/src/core/weechat.c index 675d97612..71cb3af7c 100644 --- a/src/core/weechat.c +++ b/src/core/weechat.c @@ -489,7 +489,6 @@ main (int argc, char *argv[]) gui_key_end (); /* remove all keys */ unhook_all (); /* remove all hooks */ hdata_end (); /* end hdata */ - eval_end (); /* end eval */ secure_end (); /* end secured data */ string_end (); /* end string */ weechat_shutdown (EXIT_SUCCESS, 0); /* quit WeeChat (oh no, why?) */ |