6
6
*/
7
7
PHP_FUNCTION (git_revparse_single )
8
8
{
9
- php_git2_t * result = NULL ;
9
+ php_git2_t * result = NULL , * _repo = NULL ;
10
10
git_object * out = NULL ;
11
11
zval * repo = NULL ;
12
- php_git2_t * _repo = NULL ;
13
12
char * spec = NULL ;
14
- int spec_len = 0 ;
15
- int error = 0 ;
13
+ int spec_len = 0 , error = 0 ;
16
14
17
15
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC ,
18
16
"rs" , & repo , & spec , & spec_len ) == FAILURE ) {
@@ -24,15 +22,14 @@ PHP_FUNCTION(git_revparse_single)
24
22
if (php_git2_check_error (error , "git_revparse_single" TSRMLS_CC )) {
25
23
RETURN_FALSE ;
26
24
}
27
- PHP_GIT2_MAKE_RESOURCE (result );
28
- PHP_GIT2_V (result , object ) = out ;
29
- result -> type = PHP_GIT2_TYPE_OBJECT ;
30
- result -> resource_id = PHP_GIT2_LIST_INSERT (result , git2_resource_handle );
31
- result -> should_free_v = 0 ;
32
- ZVAL_RESOURCE (return_value , result -> resource_id );
25
+ if (php_git2_make_resource (& result , PHP_GIT2_TYPE_OBJECT , out , 0 TSRMLS_CC )) {
26
+ RETURN_FALSE ;
27
+ }
28
+ ZVAL_RESOURCE (return_value , GIT2_RVAL_P (result ));
33
29
}
34
30
/* }}} */
35
31
32
+
36
33
/* {{{ proto array git_revparse_ext(resource $repo, string $spec)
37
34
*/
38
35
PHP_FUNCTION (git_revparse_ext )
@@ -58,23 +55,19 @@ PHP_FUNCTION(git_revparse_ext)
58
55
RETURN_FALSE ;
59
56
}
60
57
61
- PHP_GIT2_MAKE_RESOURCE (result );
62
- PHP_GIT2_MAKE_RESOURCE (result2 );
63
58
MAKE_STD_ZVAL (array );
64
59
MAKE_STD_ZVAL (a );
65
60
MAKE_STD_ZVAL (b );
66
61
67
- PHP_GIT2_V (result , object ) = object_out ;
68
- result -> type = PHP_GIT2_TYPE_OBJECT ;
69
- result -> resource_id = PHP_GIT2_LIST_INSERT (result , git2_resource_handle );
70
- result -> should_free_v = 0 ;
71
- ZVAL_RESOURCE (a , result -> resource_id );
62
+ if (php_git2_make_resource (& result , PHP_GIT2_TYPE_OBJECT , object_out , 0 TSRMLS_CC )) {
63
+ RETURN_FALSE ;
64
+ }
65
+ ZVAL_RESOURCE (a , GIT2_RVAL_P (result ));
72
66
73
- PHP_GIT2_V (result2 , reference ) = reference_out ;
74
- result2 -> type = PHP_GIT2_TYPE_REFERENCE ;
75
- result2 -> resource_id = PHP_GIT2_LIST_INSERT (result2 , git2_resource_handle );
76
- result2 -> should_free_v = 0 ;
77
- ZVAL_RESOURCE (b , result -> resource_id );
67
+ if (php_git2_make_resource (& result2 , PHP_GIT2_TYPE_REFERENCE , reference_out , 0 TSRMLS_CC )) {
68
+ RETURN_FALSE ;
69
+ }
70
+ ZVAL_RESOURCE (b , GIT2_RVAL_P (result2 ));
78
71
79
72
array_init (array );
80
73
add_next_index_zval (array , a );
@@ -108,20 +101,15 @@ PHP_FUNCTION(git_revparse)
108
101
RETURN_FALSE ;
109
102
}
110
103
MAKE_STD_ZVAL (result );
111
- MAKE_STD_ZVAL (from );
112
- MAKE_STD_ZVAL (to );
113
-
114
- PHP_GIT2_V (_from , object ) = revspec .from ;
115
- _from -> type = PHP_GIT2_TYPE_OBJECT ;
116
- _from -> resource_id = PHP_GIT2_LIST_INSERT (_from , git2_resource_handle );
117
- _from -> should_free_v = 0 ;
118
- ZVAL_RESOURCE (from , _from -> resource_id );
119
-
120
- PHP_GIT2_V (_to , object ) = revspec .to ;
121
- _to -> type = PHP_GIT2_TYPE_OBJECT ;
122
- _to -> resource_id = PHP_GIT2_LIST_INSERT (_to , git2_resource_handle );
123
- _to -> should_free_v = 0 ;
124
- ZVAL_RESOURCE (to , _to -> resource_id );
104
+ if (php_git2_make_resource (& _from , PHP_GIT2_TYPE_OBJECT , revspec .from , 0 TSRMLS_CC )) {
105
+ RETURN_FALSE ;
106
+ }
107
+ ZVAL_RESOURCE (from , GIT2_RVAL_P (_from ));
108
+
109
+ if (php_git2_make_resource (& _to , PHP_GIT2_TYPE_OBJECT , revspec .to , 0 TSRMLS_CC )) {
110
+ RETURN_FALSE ;
111
+ }
112
+ ZVAL_RESOURCE (to , GIT2_RVAL_P (_to ));
125
113
126
114
array_init (result );
127
115
add_assoc_zval_ex (result , ZEND_STRS ("from" ), from );
0 commit comments