Skip to content

Commit

Permalink
php: add forget_function function
Browse files Browse the repository at this point in the history
  • Loading branch information
adsr committed Mar 12, 2017
1 parent 02add51 commit ad18cf7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/plugins/php/weechat-php-api.c
Original file line number Diff line number Diff line change
Expand Up @@ -4249,7 +4249,7 @@ PHP_FUNCTION(weechat_window_set_title)
RETURN_NULL();
}

PHP_FUNCTION(forget_class)
static void forget_hash_entry (HashTable *ht, INTERNAL_FUNCTION_PARAMETERS)
{
zend_string *class_name;
zend_string *lc_name;
Expand All @@ -4260,21 +4260,28 @@ PHP_FUNCTION(forget_class)
}
if (ZSTR_VAL(class_name)[0] == '\\')
{
lc_name = zend_string_alloc(ZSTR_LEN(class_name) - 1, 0);
zend_str_tolower_copy(ZSTR_VAL(lc_name), ZSTR_VAL(class_name) + 1, ZSTR_LEN(class_name) - 1);
lc_name = zend_string_alloc (ZSTR_LEN(class_name) - 1, 0);
zend_str_tolower_copy (ZSTR_VAL(lc_name), ZSTR_VAL(class_name) + 1, ZSTR_LEN(class_name) - 1);
}
else
{
lc_name = zend_string_tolower(class_name);
}
re = zend_hash_del(EG(class_table), lc_name);
zend_string_release(lc_name);
re = zend_hash_del (ht, lc_name);
zend_string_release (lc_name);
if (re == SUCCESS)
{
RETURN_TRUE;
}
else
{
RETURN_FALSE;
}
RETURN_FALSE;
}

PHP_FUNCTION(forget_class)
{
forget_hash_entry(EG(class_table), INTERNAL_FUNCTION_PARAM_PASSTHRU);
}

PHP_FUNCTION(forget_function)
{
forget_hash_entry(EG(function_table), INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
1 change: 1 addition & 0 deletions src/plugins/php/weechat-php-api.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,5 +219,6 @@ PHP_FUNCTION(weechat_window_get_string);
PHP_FUNCTION(weechat_window_search_with_buffer);
PHP_FUNCTION(weechat_window_set_title);
PHP_FUNCTION(forget_class);
PHP_FUNCTION(forget_function);

#endif /* WEECHAT_PHP_API_H */
1 change: 1 addition & 0 deletions src/plugins/php/weechat-php.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ const zend_function_entry weechat_functions[] = {
PHP_FE(weechat_window_search_with_buffer, NULL)
PHP_FE(weechat_window_set_title, NULL)
PHP_FE(forget_class, NULL)
PHP_FE(forget_function, NULL)
PHP_FE_END
};

Expand Down

0 comments on commit ad18cf7

Please sign in to comment.