projects
/
m6w6
/
ext-http
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
use correct object handler to free the object
[m6w6/ext-http]
/
php_http_options.c
diff --git
a/php_http_options.c
b/php_http_options.c
index ca455a7a82c3d696908e55fbf0bd6afdb95992d6..7a01b9cc385586fe5d7570af136db402d12be796 100644
(file)
--- a/
php_http_options.c
+++ b/
php_http_options.c
@@
-6,12
+6,22
@@
| modification, are permitted provided that the conditions mentioned |
| in the accompanying LICENSE file are met. |
+--------------------------------------------------------------------+
| modification, are permitted provided that the conditions mentioned |
| in the accompanying LICENSE file are met. |
+--------------------------------------------------------------------+
- | Copyright (c) 2004-201
3
, Michael Wallner <mike@php.net> |
+ | Copyright (c) 2004-201
4
, Michael Wallner <mike@php.net> |
+--------------------------------------------------------------------+
*/
#include "php_http_api.h"
+--------------------------------------------------------------------+
*/
#include "php_http_api.h"
+static void php_http_options_hash_dtor(zval *pData)
+{
+ php_http_option_t *opt = Z_PTR_P(pData);
+
+ zval_ptr_dtor(&opt->defval);
+ zend_hash_destroy(&opt->suboptions.options);
+ zend_string_release(opt->name);
+ efree(opt);
+}
+
php_http_options_t *php_http_options_init(php_http_options_t *registry, zend_bool persistent)
{
if (!registry) {
php_http_options_t *php_http_options_init(php_http_options_t *registry, zend_bool persistent)
{
if (!registry) {
@@
-21,18
+31,19
@@
php_http_options_t *php_http_options_init(php_http_options_t *registry, zend_boo
}
registry->persistent = persistent;
}
registry->persistent = persistent;
- zend_hash_init(®istry->options, 0, NULL,
(dtor_func_t) zend_hash_destroy
, persistent);
+ zend_hash_init(®istry->options, 0, NULL,
php_http_options_hash_dtor
, persistent);
return registry;
}
return registry;
}
-
STATUS
php_http_options_apply(php_http_options_t *registry, HashTable *options, void *userdata)
+
ZEND_RESULT_CODE
php_http_options_apply(php_http_options_t *registry, HashTable *options, void *userdata)
{
{
- HashPosition pos;
- zval *val;
+ zval *entry, *val;
php_http_option_t *opt;
php_http_option_t *opt;
- FOREACH_HASH_VAL(pos, ®istry->options, opt) {
+ ZEND_HASH_FOREACH_VAL(®istry->options, entry)
+ {
+ opt = Z_PTR_P(entry);
if (!(val = registry->getter(opt, options, userdata))) {
val = &opt->defval;
}
if (!(val = registry->getter(opt, options, userdata))) {
val = &opt->defval;
}
@@
-44,6
+55,8
@@
STATUS php_http_options_apply(php_http_options_t *registry, HashTable *options,
return FAILURE;
}
}
return FAILURE;
}
}
+ ZEND_HASH_FOREACH_END();
+
return SUCCESS;
}
return SUCCESS;
}
@@
-63,7
+76,7
@@
void php_http_options_free(php_http_options_t **registry)
php_http_option_t *php_http_option_register(php_http_options_t *registry, const char *name_str, size_t name_len, ulong option, zend_uchar type)
{
php_http_option_t *php_http_option_register(php_http_options_t *registry, const char *name_str, size_t name_len, ulong option, zend_uchar type)
{
- php_http_option_t opt
, *dst = NULL
;
+ php_http_option_t opt;
memset(&opt, 0, sizeof(opt));
memset(&opt, 0, sizeof(opt));
@@
-71,14
+84,17
@@
php_http_option_t *php_http_option_register(php_http_options_t *registry, const
opt.suboptions.getter = registry->getter;
opt.suboptions.setter = registry->setter;
opt.suboptions.getter = registry->getter;
opt.suboptions.setter = registry->setter;
- opt.name
.h = zend_hash_func(opt.name.s = name_str, opt.name.l = name_len + 1
);
+ opt.name
= zend_string_init(name_str, name_len, registry->persistent
);
opt.type = type;
opt.option = option;
opt.type = type;
opt.option = option;
- INIT_ZVAL(opt.defval);
switch ((opt.type = type)) {
switch ((opt.type = type)) {
- case IS_BOOL:
- ZVAL_BOOL(&opt.defval, 0);
+ case IS_TRUE:
+ ZVAL_TRUE(&opt.defval);
+ break;
+
+ case IS_FALSE:
+ ZVAL_FALSE(&opt.defval);
break;
case IS_LONG:
break;
case IS_LONG:
@@
-86,7
+102,7
@@
php_http_option_t *php_http_option_register(php_http_options_t *registry, const
break;
case IS_STRING:
break;
case IS_STRING:
- ZVAL_
STRINGL(&opt.defval, NULL, 0, 0
);
+ ZVAL_
EMPTY_STRING(&opt.defval
);
break;
case IS_DOUBLE:
break;
case IS_DOUBLE:
@@
-98,18
+114,13
@@
php_http_option_t *php_http_option_register(php_http_options_t *registry, const
break;
}
break;
}
- zend_hash_quick_update(®istry->options, opt.name.s, opt.name.l, opt.name.h, (void *) &opt, sizeof(opt), (void *) &dst);
- return dst;
+ return zend_hash_update_mem(®istry->options, opt.name, &opt, sizeof(opt));
}
zval *php_http_option_get(php_http_option_t *opt, HashTable *options, void *userdata)
{
if (options) {
}
zval *php_http_option_get(php_http_option_t *opt, HashTable *options, void *userdata)
{
if (options) {
- zval **zoption;
-
- if (SUCCESS == zend_hash_quick_find(options, opt->name.s, opt->name.l, opt->name.h, (void *) &zoption)) {
- return *zoption;
- }
+ return zend_hash_find(options, opt->name);
}
return NULL;
}
return NULL;