simplify
[m6w6/ext-pq] / src / php_pqstm.c
index 10d57686ae9d5c91fc6db135c00b9c84ef776243..d360d0dc97450dc0f823bb55014d2aa12f3cfc5a 100644 (file)
@@ -29,7 +29,7 @@ zend_class_entry *php_pqstm_class_entry;
 static zend_object_handlers php_pqstm_object_handlers;
 static HashTable php_pqstm_object_prophandlers;
 
-static void php_pqstm_deallocate(php_pqstm_object_t *obj, zend_bool async, zend_bool silent)
+static void php_pqstm_deallocate(php_pqstm_object_t *obj, zend_bool async, zend_bool silent TSRMLS_DC)
 {
        if (obj->intern->allocated) {
                char *quoted_name = PQescapeIdentifier(obj->intern->conn->intern->conn, obj->intern->name, strlen(obj->intern->name));
@@ -75,10 +75,11 @@ static void php_pqstm_object_free(void *o TSRMLS_DC)
        if (obj->intern) {
                if (obj->intern->conn->intern) {
                        php_pq_callback_dtor(&obj->intern->conn->intern->onevent);
-                       php_pqstm_deallocate(obj, 0, 1);
+                       php_pqstm_deallocate(obj, 0, 1 TSRMLS_CC);
                        php_pq_object_delref(obj->intern->conn TSRMLS_CC);
                }
                efree(obj->intern->name);
+               efree(obj->intern->query);
                zend_hash_destroy(&obj->intern->bound);
                if (obj->intern->params) {
                        php_pq_params_free(&obj->intern->params);
@@ -139,19 +140,12 @@ static void php_pqstm_object_read_query(zval *object, void *o, zval *return_valu
        RETVAL_STRING(obj->intern->query, 1);
 }
 
-static void php_pqstm_object_read_types(zval *object, void *o, zval *return_value)
+static void php_pqstm_object_read_types(zval *object, void *o, zval *return_value TSRMLS_DC)
 {
        int i;
-       HashTable *ht;
-       php_pqstm_object_t *obj;
-
-       obj = (php_pqstm_object_t *)o;
-       ht = (HashTable *)emalloc(sizeof(HashTable));
-
-       zend_hash_init(ht, obj->intern->params->type.count, NULL, ZVAL_PTR_DTOR, 0);
-       Z_TYPE_P(return_value) = IS_ARRAY;
-       Z_ARRVAL_P(return_value) = ht;
+       php_pqstm_object_t *obj = o;
 
+       array_init_size(return_value, obj->intern->params->type.count);
        for (i = 0; i < obj->intern->params->type.count; i++) {
                add_next_index_long(return_value, (long)obj->intern->params->type.oids[i]);
        }