Skip to content

Commit 9343af5

Browse files
committed
Fix
1 parent 6331ace commit 9343af5

20 files changed

+50
-61
lines changed

php_phongo.h

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -60,29 +60,18 @@ ZEND_TSRMLS_CACHE_EXTERN()
6060

6161
zend_object_handlers* phongo_get_std_object_handlers(void);
6262

63-
#define PHONGO_RETURN_PROPS(is_temp, props) \
64-
if (!(is_temp)) { \
65-
GC_ADDREF(props); \
66-
} \
67-
return props;
68-
69-
#define PHONGO_GET_PROPERTY_HASH_INIT_PROPS(is_temp, intern, props, size) \
70-
do { \
71-
if (!(intern)->php_properties) { \
72-
ALLOC_HASHTABLE((intern)->php_properties); \
73-
zend_hash_init((intern)->php_properties, 0, NULL, ZVAL_PTR_DTOR, 0); \
74-
} \
75-
if (is_temp) { \
76-
(props) = zend_array_dup((intern)->php_properties); \
77-
} else { \
78-
(props) = zend_array_dup((intern)->php_properties); \
79-
if ((intern)->properties) { \
80-
HashTable* __tmp = (intern)->properties; \
81-
(intern)->properties = NULL; \
82-
zend_hash_release(__tmp); \
83-
} \
84-
(intern)->properties = (props); \
85-
} \
63+
#define PHONGO_GET_PROPERTY_HASH_INIT_PROPS(is_temp, intern, props, size) \
64+
do { \
65+
if (is_temp) { \
66+
ALLOC_HASHTABLE(props); \
67+
zend_hash_init((props), (size), NULL, ZVAL_PTR_DTOR, 0); \
68+
} else if ((intern)->properties) { \
69+
(props) = (intern)->properties; \
70+
} else { \
71+
ALLOC_HASHTABLE(props); \
72+
zend_hash_init((props), (size), NULL, ZVAL_PTR_DTOR, 0); \
73+
(intern)->properties = (props); \
74+
} \
8675
} while (0)
8776

8877
#define PHONGO_GET_PROPERTY_HASH_FREE_PROPS(is_temp, props) \

src/BSON/Binary.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ static HashTable* php_phongo_binary_get_properties_hash(zend_object* object, boo
7373
PHONGO_GET_PROPERTY_HASH_INIT_PROPS(is_temp, intern, props, 2);
7474

7575
if (!intern->data) {
76-
PHONGO_RETURN_PROPS(is_temp, props);
76+
return props;
7777
}
7878

7979
{
@@ -86,7 +86,7 @@ static HashTable* php_phongo_binary_get_properties_hash(zend_object* object, boo
8686
zend_hash_str_update(props, "type", sizeof("type") - 1, &type);
8787
}
8888

89-
PHONGO_RETURN_PROPS(is_temp, props);
89+
return props;
9090
}
9191

9292
/* Construct a new BSON binary type */

src/BSON/DBPointer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ HashTable* php_phongo_dbpointer_get_properties_hash(zend_object* object, bool is
7474
PHONGO_GET_PROPERTY_HASH_INIT_PROPS(is_temp, intern, props, 2);
7575

7676
if (!intern->ref) {
77-
PHONGO_RETURN_PROPS(is_temp, props);
77+
return props;
7878
}
7979

8080
{
@@ -86,7 +86,7 @@ HashTable* php_phongo_dbpointer_get_properties_hash(zend_object* object, bool is
8686
zend_hash_str_update(props, "id", sizeof("id") - 1, &id);
8787
}
8888

89-
PHONGO_RETURN_PROPS(is_temp, props);
89+
return props;
9090
}
9191

9292
PHONGO_DISABLED_CONSTRUCTOR(MongoDB_BSON_DBPointer)

src/BSON/Decimal128.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static HashTable* php_phongo_decimal128_get_properties_hash(zend_object* object,
6464
PHONGO_GET_PROPERTY_HASH_INIT_PROPS(is_temp, intern, props, 1);
6565

6666
if (!intern->initialized) {
67-
PHONGO_RETURN_PROPS(is_temp, props);
67+
return props;
6868
}
6969

7070
bson_decimal128_to_string(&intern->decimal, outbuf);
@@ -76,7 +76,7 @@ static HashTable* php_phongo_decimal128_get_properties_hash(zend_object* object,
7676
zend_hash_str_update(props, "dec", sizeof("dec") - 1, &dec);
7777
}
7878

79-
PHONGO_RETURN_PROPS(is_temp, props);
79+
return props;
8080
}
8181

8282
/* Construct a new BSON Decimal128 type */

src/BSON/Document.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static HashTable* php_phongo_document_get_properties_hash(zend_object* object, b
6565
PHONGO_GET_PROPERTY_HASH_INIT_PROPS(is_temp, intern, props, size);
6666

6767
if (!intern->bson) {
68-
PHONGO_RETURN_PROPS(is_temp, props);
68+
return props;
6969
}
7070

7171
{
@@ -75,7 +75,7 @@ static HashTable* php_phongo_document_get_properties_hash(zend_object* object, b
7575
zend_hash_str_update(props, "data", sizeof("data") - 1, &data);
7676
}
7777

78-
PHONGO_RETURN_PROPS(is_temp, props);
78+
return props;
7979
}
8080

8181
PHONGO_DISABLED_CONSTRUCTOR(MongoDB_BSON_Document)
@@ -526,7 +526,7 @@ static HashTable* php_phongo_document_get_debug_info(zend_object* object, int* i
526526
zend_hash_str_update(props, "value", sizeof("value") - 1, &state.zchild);
527527
}
528528

529-
PHONGO_RETURN_PROPS(is_temp, props);
529+
return props;
530530

531531
failure:
532532
PHONGO_GET_PROPERTY_HASH_FREE_PROPS(is_temp, props);

src/BSON/Int64.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ HashTable* php_phongo_int64_get_properties_hash(zend_object* object, bool is_tem
7272
PHONGO_GET_PROPERTY_HASH_INIT_PROPS(is_temp, intern, props, 2);
7373

7474
if (!intern->initialized) {
75-
PHONGO_RETURN_PROPS(is_temp, props);
75+
return props;
7676
}
7777

7878
{
@@ -82,7 +82,7 @@ HashTable* php_phongo_int64_get_properties_hash(zend_object* object, bool is_tem
8282
zend_hash_str_update(props, "integer", sizeof("integer") - 1, &value);
8383
}
8484

85-
PHONGO_RETURN_PROPS(is_temp, props);
85+
return props;
8686
}
8787

8888
static PHP_METHOD(MongoDB_BSON_Int64, __construct)

src/BSON/Iterator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ static HashTable* php_phongo_iterator_get_properties_hash(zend_object* object, b
165165
zend_hash_str_update(props, "bson", sizeof("bson") - 1, &intern->bson);
166166
Z_TRY_ADDREF(intern->bson);
167167

168-
PHONGO_RETURN_PROPS(is_temp, props);
168+
return props;
169169
}
170170

171171
PHONGO_DISABLED_CONSTRUCTOR(MongoDB_BSON_Iterator)

src/BSON/Javascript.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ HashTable* php_phongo_javascript_get_properties_hash(zend_object* object, bool i
7979
PHONGO_GET_PROPERTY_HASH_INIT_PROPS(is_temp, intern, props, 2);
8080

8181
if (!intern->code) {
82-
PHONGO_RETURN_PROPS(is_temp, props);
82+
return props;
8383
}
8484

8585
{
@@ -106,7 +106,7 @@ HashTable* php_phongo_javascript_get_properties_hash(zend_object* object, bool i
106106
}
107107
}
108108

109-
PHONGO_RETURN_PROPS(is_temp, props);
109+
return props;
110110

111111
failure:
112112
PHONGO_GET_PROPERTY_HASH_FREE_PROPS(is_temp, props);

src/BSON/ObjectId.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static HashTable* php_phongo_objectid_get_properties_hash(zend_object* object, b
8787
PHONGO_GET_PROPERTY_HASH_INIT_PROPS(is_temp, intern, props, 1);
8888

8989
if (!intern->initialized) {
90-
PHONGO_RETURN_PROPS(is_temp, props);
90+
return props;
9191
}
9292

9393
{
@@ -97,7 +97,7 @@ static HashTable* php_phongo_objectid_get_properties_hash(zend_object* object, b
9797
zend_hash_str_update(props, "oid", sizeof("oid") - 1, &zv);
9898
}
9999

100-
PHONGO_RETURN_PROPS(is_temp, props);
100+
return props;
101101
}
102102

103103
/* Constructs a new BSON ObjectId type, optionally from a hex string. */

src/BSON/PackedArray.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static HashTable* php_phongo_packedarray_get_properties_hash(zend_object* object
6666
PHONGO_GET_PROPERTY_HASH_INIT_PROPS(is_temp, intern, props, size);
6767

6868
if (!intern->bson) {
69-
PHONGO_RETURN_PROPS(is_temp, props);
69+
return props;
7070
}
7171

7272
{
@@ -76,7 +76,7 @@ static HashTable* php_phongo_packedarray_get_properties_hash(zend_object* object
7676
zend_hash_str_update(props, "data", sizeof("data") - 1, &data);
7777
}
7878

79-
PHONGO_RETURN_PROPS(is_temp, props);
79+
return props;
8080
}
8181

8282
static bool php_phongo_packedarray_to_json(zval* return_value, bson_json_mode_t mode, const bson_t* bson)
@@ -511,7 +511,7 @@ static HashTable* php_phongo_packedarray_get_debug_info(zend_object* object, int
511511
zend_hash_str_update(props, "value", sizeof("value") - 1, &state.zchild);
512512
}
513513

514-
PHONGO_RETURN_PROPS(is_temp, props);
514+
return props;
515515

516516
failure:
517517
PHONGO_GET_PROPERTY_HASH_FREE_PROPS(is_temp, props);

0 commit comments

Comments
 (0)