refactor auto conversion
[m6w6/ext-pq] / src / php_pqtypes.c
index e0daddecbb804670e82f9eb987fe160c31add956..ff9c10d7a4b31e2a0ebabb987cf23ac660422719 100644 (file)
@@ -136,6 +136,7 @@ static int php_pqtypes_object_has_dimension(zval *object, zval *member, int chec
                                        return Z_TYPE_PP(data) != IS_NULL;
                                }
                                efree(key_str);
+                               key_str = NULL;
                        } else {
                                if (SUCCESS == zend_hash_index_find(&obj->intern->types, index, (void *) &data)) {
                                        return Z_TYPE_PP(data) != IS_NULL;
@@ -172,9 +173,10 @@ static zval *php_pqtypes_object_read_dimension(zval *object, zval *member, int t
                                return *data;
                        }
                }
-               if (key_str) {
-                       efree(key_str);
-               }
+       }
+
+       if (key_str) {
+               efree(key_str);
        }
 
        return NULL;
@@ -354,14 +356,9 @@ PHP_MINIT_FUNCTION(pqtypes)
        ph.read = php_pqtypes_object_read_connection;
        zend_hash_add(&php_pqtypes_object_prophandlers, "connection", sizeof("connection"), (void *) &ph, sizeof(ph), NULL);
 
-#ifdef HAVE_PHP_PQ_TYPE_H
 #      undef PHP_PQ_TYPE
 #      define PHP_PQ_TYPE(name, oid) zend_declare_class_constant_long(php_pqtypes_class_entry, ZEND_STRL(name), oid TSRMLS_CC);
 #      include "php_pq_type.h"
-       zend_declare_class_constant_bool(php_pqtypes_class_entry, ZEND_STRL("DEFINED"), 1 TSRMLS_CC);
-#else
-       zend_declare_class_constant_bool(php_pqtypes_class_entry, ZEND_STRL("DEFINED"), 0 TSRMLS_CC);
-#endif
 
        return SUCCESS;
 }