6
6
*/
7
7
PHP_FUNCTION (git_branch_create )
8
8
{
9
- php_git2_t * result = NULL ;
9
+ php_git2_t * result = NULL , * _repo = NULL , * _target = NULL ;
10
10
git_reference * out = NULL ;
11
- zval * repo = NULL ;
12
- php_git2_t * _repo = NULL ;
11
+ zval * repo = NULL , * target = NULL ;
13
12
char * branch_name = NULL ;
14
- int branch_name_len = 0 ;
15
- zval * target = NULL ;
16
- php_git2_t * _target = NULL ;
13
+ int branch_name_len = 0 , error = 0 ;
17
14
long force = 0 ;
18
- int error = 0 ;
19
15
20
16
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC ,
21
17
"rsrl" , & repo , & branch_name , & branch_name_len , & target , & force ) == FAILURE ) {
@@ -28,12 +24,10 @@ PHP_FUNCTION(git_branch_create)
28
24
if (php_git2_check_error (error , "git_branch_create" TSRMLS_CC )) {
29
25
RETURN_FALSE ;
30
26
}
31
- PHP_GIT2_MAKE_RESOURCE (result );
32
- PHP_GIT2_V (result , reference ) = out ;
33
- result -> type = PHP_GIT2_TYPE_REFERENCE ;
34
- result -> resource_id = PHP_GIT2_LIST_INSERT (result , git2_resource_handle );
35
- result -> should_free_v = 1 ;
36
- ZVAL_RESOURCE (return_value , result -> resource_id );
27
+ if (php_git2_make_resource (& result , PHP_GIT2_TYPE_REFERENCE , out , 1 TSRMLS_CC )) {
28
+ RETURN_FALSE ;
29
+ }
30
+ ZVAL_RESOURCE (return_value , GIT2_RVAL_P (result ));
37
31
}
38
32
/* }}} */
39
33
@@ -63,12 +57,11 @@ PHP_FUNCTION(git_branch_delete)
63
57
*/
64
58
PHP_FUNCTION (git_branch_iterator_new )
65
59
{
66
- php_git2_t * result = NULL ;
60
+ php_git2_t * result = NULL , * _repo = NULL ;
67
61
git_branch_iterator * out = NULL ;
68
62
zval * repo = NULL ;
69
- php_git2_t * _repo = NULL ;
70
- long list_flags = 0 ;
71
63
int error = 0 ;
64
+ long list_flags = 0 ;
72
65
73
66
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC ,
74
67
"rl" , & repo , & list_flags ) == FAILURE ) {
@@ -80,12 +73,10 @@ PHP_FUNCTION(git_branch_iterator_new)
80
73
if (php_git2_check_error (error , "git_branch_iterator_new" TSRMLS_CC )) {
81
74
RETURN_FALSE ;
82
75
}
83
- PHP_GIT2_MAKE_RESOURCE (result );
84
- PHP_GIT2_V (result , branch_iterator ) = out ;
85
- result -> type = PHP_GIT2_TYPE_BRANCH_ITERATOR ;
86
- result -> resource_id = PHP_GIT2_LIST_INSERT (result , git2_resource_handle );
87
- result -> should_free_v = 0 ;
88
- ZVAL_RESOURCE (return_value , result -> resource_id );
76
+ if (php_git2_make_resource (& result , PHP_GIT2_TYPE_BRANCH_ITERATOR , out , 1 TSRMLS_CC )) {
77
+ RETURN_FALSE ;
78
+ }
79
+ ZVAL_RESOURCE (return_value , GIT2_RVAL_P (result ));
89
80
}
90
81
/* }}} */
91
82
@@ -94,11 +85,10 @@ PHP_FUNCTION(git_branch_iterator_new)
94
85
*/
95
86
PHP_FUNCTION (git_branch_next )
96
87
{
97
- php_git2_t * result = NULL ;
88
+ php_git2_t * result = NULL , * _iter = NULL ;
98
89
git_reference * out = NULL ;
99
- long out_type = 0 ;
100
90
zval * iter = NULL ;
101
- php_git2_t * _iter = NULL ;
91
+ long out_type = 0 ;
102
92
int error = 0 ;
103
93
104
94
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC ,
@@ -111,16 +101,13 @@ PHP_FUNCTION(git_branch_next)
111
101
if (php_git2_check_error (error , "git_branch_next" TSRMLS_CC )) {
112
102
RETURN_FALSE ;
113
103
}
114
- PHP_GIT2_MAKE_RESOURCE (result );
115
- PHP_GIT2_V (result , reference ) = out ;
116
- result -> type = PHP_GIT2_TYPE_REFERENCE ;
117
- result -> resource_id = PHP_GIT2_LIST_INSERT (result , git2_resource_handle );
118
- result -> should_free_v = 0 ;
119
- ZVAL_RESOURCE (return_value , result -> resource_id );
104
+ if (php_git2_make_resource (& result , PHP_GIT2_TYPE_REFERENCE , out , 1 TSRMLS_CC )) {
105
+ RETURN_FALSE ;
106
+ }
107
+ ZVAL_RESOURCE (return_value , GIT2_RVAL_P (result ));
120
108
}
121
109
/* }}} */
122
110
123
-
124
111
/* {{{ proto void git_branch_iterator_free(resource $iter)
125
112
*/
126
113
PHP_FUNCTION (git_branch_iterator_free )
@@ -134,8 +121,9 @@ PHP_FUNCTION(git_branch_iterator_free)
134
121
}
135
122
136
123
ZEND_FETCH_RESOURCE (_iter , php_git2_t * , & iter , -1 , PHP_GIT2_RESOURCE_NAME , git2_resource_handle );
137
- if (_iter -> should_free_v ) {
124
+ if (GIT2_SHOULD_FREE ( _iter ) ) {
138
125
git_branch_iterator_free (PHP_GIT2_V (_iter , branch_iterator ));
126
+ GIT2_SHOULD_FREE (_iter ) = 0 ;
139
127
};
140
128
zval_ptr_dtor (& iter );
141
129
}
@@ -145,14 +133,12 @@ PHP_FUNCTION(git_branch_iterator_free)
145
133
*/
146
134
PHP_FUNCTION (git_branch_move )
147
135
{
148
- php_git2_t * result = NULL ;
136
+ php_git2_t * result = NULL , * _branch = NULL ;
149
137
git_reference * out = NULL ;
150
138
zval * branch = NULL ;
151
- php_git2_t * _branch = NULL ;
152
139
char * new_branch_name = NULL ;
153
- int new_branch_name_len = 0 ;
140
+ int new_branch_name_len = 0 , error = 0 ;
154
141
long force = 0 ;
155
- int error = 0 ;
156
142
157
143
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC ,
158
144
"rsl" , & branch , & new_branch_name , & new_branch_name_len , & force ) == FAILURE ) {
@@ -164,27 +150,24 @@ PHP_FUNCTION(git_branch_move)
164
150
if (php_git2_check_error (error , "git_branch_move" TSRMLS_CC )) {
165
151
RETURN_FALSE ;
166
152
}
167
- PHP_GIT2_MAKE_RESOURCE (result );
168
- PHP_GIT2_V (result , reference ) = out ;
169
- result -> type = PHP_GIT2_TYPE_REFERENCE ;
170
- result -> resource_id = PHP_GIT2_LIST_INSERT (result , git2_resource_handle );
171
- result -> should_free_v = 0 ;
172
- ZVAL_RESOURCE (return_value , result -> resource_id );
153
+ if (php_git2_make_resource (& result , PHP_GIT2_TYPE_REFERENCE , out , 1 TSRMLS_CC )) {
154
+ RETURN_FALSE ;
155
+ }
156
+ ZVAL_RESOURCE (return_value , GIT2_RVAL_P (result ));
173
157
}
174
158
/* }}} */
175
159
176
- /* {{{ proto resource git_branch_lookup(resource $repo, string $branch_name, long $branch_type)
160
+
161
+ /* {{{ proto resource git_branch_lookup(resource $repo, string $branch_name, $branch_type)
177
162
*/
178
163
PHP_FUNCTION (git_branch_lookup )
179
164
{
180
- php_git2_t * result = NULL ;
165
+ php_git2_t * result = NULL , * _repo = NULL ;
181
166
git_reference * out = NULL ;
182
167
zval * repo = NULL ;
183
- php_git2_t * _repo = NULL ;
184
168
char * branch_name = NULL ;
185
- int branch_name_len = 0 ;
169
+ int branch_name_len = 0 , error = 0 ;
186
170
long branch_type = 0 ;
187
- int error = 0 ;
188
171
189
172
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC ,
190
173
"rsl" , & repo , & branch_name , & branch_name_len , & branch_type ) == FAILURE ) {
@@ -196,16 +179,13 @@ PHP_FUNCTION(git_branch_lookup)
196
179
if (php_git2_check_error (error , "git_branch_lookup" TSRMLS_CC )) {
197
180
RETURN_FALSE ;
198
181
}
199
- PHP_GIT2_MAKE_RESOURCE (result );
200
- PHP_GIT2_V (result , reference ) = out ;
201
- result -> type = PHP_GIT2_TYPE_REFERENCE ;
202
- result -> resource_id = PHP_GIT2_LIST_INSERT (result , git2_resource_handle );
203
- result -> should_free_v = 0 ;
204
- ZVAL_RESOURCE (return_value , result -> resource_id );
182
+ if (php_git2_make_resource (& result , PHP_GIT2_TYPE_REFERENCE , out , 1 TSRMLS_CC )) {
183
+ RETURN_FALSE ;
184
+ }
185
+ ZVAL_RESOURCE (return_value , GIT2_RVAL_P (result ));
205
186
}
206
187
/* }}} */
207
188
208
-
209
189
/* {{{ proto resource git_branch_name(resource $ref)
210
190
*/
211
191
PHP_FUNCTION (git_branch_name )
@@ -234,10 +214,9 @@ PHP_FUNCTION(git_branch_name)
234
214
*/
235
215
PHP_FUNCTION (git_branch_upstream )
236
216
{
237
- php_git2_t * result = NULL ;
217
+ php_git2_t * result = NULL , * _branch = NULL ;
238
218
git_reference * out = NULL ;
239
219
zval * branch = NULL ;
240
- php_git2_t * _branch = NULL ;
241
220
int error = 0 ;
242
221
243
222
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC ,
@@ -250,15 +229,14 @@ PHP_FUNCTION(git_branch_upstream)
250
229
if (php_git2_check_error (error , "git_branch_upstream" TSRMLS_CC )) {
251
230
RETURN_FALSE ;
252
231
}
253
- PHP_GIT2_MAKE_RESOURCE (result );
254
- PHP_GIT2_V (result , reference ) = out ;
255
- result -> type = PHP_GIT2_TYPE_REFERENCE ;
256
- result -> resource_id = PHP_GIT2_LIST_INSERT (result , git2_resource_handle );
257
- result -> should_free_v = 0 ;
258
- ZVAL_RESOURCE (return_value , result -> resource_id );
232
+ if (php_git2_make_resource (& result , PHP_GIT2_TYPE_REFERENCE , out , 1 TSRMLS_CC )) {
233
+ RETURN_FALSE ;
234
+ }
235
+ ZVAL_RESOURCE (return_value , GIT2_RVAL_P (result ));
259
236
}
260
237
/* }}} */
261
238
239
+
262
240
/* {{{ proto resource git_branch_upstream_name(resource $repo, string $canonical_branch_name)
263
241
*/
264
242
PHP_FUNCTION (git_branch_upstream_name )
0 commit comments