Skip to content

Commit efd9181

Browse files
committed
Re-use cursor_free_current() in cursor_free()
With this change, all visitor_data.zchild freeing is now done through the same function.
1 parent c454d27 commit efd9181

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

php_phongo.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,6 +1541,14 @@ php_phongo_writeresult_t *php_phongo_writeresult_get_from_bulkwriteexception(zva
15411541
return (php_phongo_writeresult_t *)zend_object_store_get_object(wr TSRMLS_CC);
15421542
}
15431543

1544+
static void php_phongo_cursor_free_current(php_phongo_cursor_t *cursor) /* {{{ */
1545+
{
1546+
if (cursor->visitor_data.zchild) {
1547+
zval_ptr_dtor(&cursor->visitor_data.zchild);
1548+
cursor->visitor_data.zchild = NULL;
1549+
}
1550+
} /* }}} */
1551+
15441552
void php_phongo_cursor_free(php_phongo_cursor_t *cursor)
15451553
{
15461554
if (cursor->firstBatch) {
@@ -1551,20 +1559,9 @@ void php_phongo_cursor_free(php_phongo_cursor_t *cursor)
15511559
mongoc_cursor_destroy(cursor->cursor);
15521560
cursor->cursor = NULL;
15531561
}
1554-
if (cursor->visitor_data.zchild) {
1555-
zval_ptr_dtor(&cursor->visitor_data.zchild);
1556-
cursor->visitor_data.zchild = NULL;
1557-
}
1562+
php_phongo_cursor_free_current(cursor);
15581563
}
15591564

1560-
static void php_phongo_cursor_free_current(php_phongo_cursor_t *cursor) /* {{{ */
1561-
{
1562-
if (cursor->visitor_data.zchild) {
1563-
zval_ptr_dtor(&cursor->visitor_data.zchild);
1564-
cursor->visitor_data.zchild = NULL;
1565-
}
1566-
} /* }}} */
1567-
15681565
/* {{{ Iterator */
15691566
static void php_phongo_cursor_iterator_dtor(zend_object_iterator *iter TSRMLS_DC) /* {{{ */
15701567
{

0 commit comments

Comments
 (0)