moar tests
[m6w6/ext-pq] / src / php_pq_callback.c
1 /*
2 +--------------------------------------------------------------------+
3 | PECL :: pq |
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the conditions mentioned |
7 | in the accompanying LICENSE file are met. |
8 +--------------------------------------------------------------------+
9 | Copyright (c) 2013, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
11 */
12
13 #ifdef HAVE_CONFIG_H
14 # include "config.h"
15 #endif
16
17 #include <php.h>
18
19 #include "php_pq_callback.h"
20
21 void php_pq_callback_dtor(php_pq_callback_t *cb)
22 {
23 if (cb->fci.size > 0) {
24 zend_fcall_info_args_clear(&cb->fci, 1);
25 zval_ptr_dtor(&cb->fci.function_name);
26 if (cb->fci.object_ptr) {
27 zval_ptr_dtor(&cb->fci.object_ptr);
28 }
29 }
30 cb->fci.size = 0;
31 }
32
33 void php_pq_callback_addref(php_pq_callback_t *cb)
34 {
35 Z_ADDREF_P(cb->fci.function_name);
36 if (cb->fci.object_ptr) {
37 Z_ADDREF_P(cb->fci.object_ptr);
38 }
39 }
40
41 zval *php_pq_callback_to_zval(php_pq_callback_t *cb)
42 {
43 zval *zcb;
44
45 php_pq_callback_addref(cb);
46
47 if (cb->fci.object_ptr) {
48 MAKE_STD_ZVAL(zcb);
49 array_init_size(zcb, 2);
50 add_next_index_zval(zcb, cb->fci.object_ptr);
51 add_next_index_zval(zcb, cb->fci.function_name);
52 } else {
53 zcb = cb->fci.function_name;
54 }
55
56 return zcb;
57 }
58 /*
59 * Local variables:
60 * tab-width: 4
61 * c-basic-offset: 4
62 * End:
63 * vim600: noet sw=4 ts=4 fdm=marker
64 * vim<600: noet sw=4 ts=4
65 */