]> granicus.if.org Git - php/commitdiff
Remove zval **
authorXinchen Hui <laruence@php.net>
Tue, 13 May 2014 05:45:24 +0000 (13:45 +0800)
committerXinchen Hui <laruence@php.net>
Tue, 13 May 2014 05:45:24 +0000 (13:45 +0800)
ext/standard/dns_win32.c

index 5d00b07af0fe05772f46695974d20db7f7f03a65..c4895610ff3d536e6d4aa61ccfd742d844647a4b 100644 (file)
@@ -138,7 +138,7 @@ PHP_FUNCTION(dns_check_record)
 /* }}} */
 
 /* {{{ php_parserr */
-static void php_parserr(PDNS_RECORD pRec, int type_to_fetch, int store, int raw, zval **subarray)
+static void php_parserr(PDNS_RECORD pRec, int type_to_fetch, int store, int raw, zval *subarray)
 {
        int type;
        u_long ttl;
@@ -154,14 +154,15 @@ static void php_parserr(PDNS_RECORD pRec, int type_to_fetch, int store, int raw,
                return;
        }
 
-       ZVAL_NEW_ARR(*subarray);
-       add_assoc_string(*subarray, "host", pRec->pName);
-       add_assoc_string(*subarray, "class", "IN");
-       add_assoc_long(*subarray, "ttl", ttl);
+       array_init(subarray);
+
+       add_assoc_string(subarray, "host", pRec->pName);
+       add_assoc_string(subarray, "class", "IN");
+       add_assoc_long(subarray, "ttl", ttl);
 
        if (raw) {
-               add_assoc_long(*subarray, "type", type);
-               add_assoc_stringl(*subarray, "data", (char*) &pRec->Data, (uint) pRec->wDataLength);
+               add_assoc_long(subarray, "type", type);
+               add_assoc_stringl(subarray, "data", (char*) &pRec->Data, (uint) pRec->wDataLength);
                return;
        }
 
@@ -169,33 +170,33 @@ static void php_parserr(PDNS_RECORD pRec, int type_to_fetch, int store, int raw,
                case DNS_TYPE_A: {
                        IN_ADDR ipaddr;
                        ipaddr.S_un.S_addr = (pRec->Data.A.IpAddress);
-                       add_assoc_string(*subarray, "type", "A");
-                       add_assoc_string(*subarray, "ip", inet_ntoa(ipaddr));
+                       add_assoc_string(subarray, "type", "A");
+                       add_assoc_string(subarray, "ip", inet_ntoa(ipaddr));
                        break;
                }
 
                case DNS_TYPE_MX:
-                       add_assoc_string(*subarray, "type", "MX");
-                       add_assoc_long(*subarray, "pri", pRec->Data.Srv.wPriority);
+                       add_assoc_string(subarray, "type", "MX");
+                       add_assoc_long(subarray, "pri", pRec->Data.Srv.wPriority);
                        /* no break; */
 
                case DNS_TYPE_CNAME:
                        if (type == DNS_TYPE_CNAME) {
-                               add_assoc_string(*subarray, "type", "CNAME");
+                               add_assoc_string(subarray, "type", "CNAME");
                        }
                        /* no break; */
 
                case DNS_TYPE_NS:
                        if (type == DNS_TYPE_NS) {
-                               add_assoc_string(*subarray, "type", "NS");
+                               add_assoc_string(subarray, "type", "NS");
                        }
                        /* no break; */
 
                case DNS_TYPE_PTR:
                        if (type == DNS_TYPE_PTR) {
-                               add_assoc_string(*subarray, "type", "PTR");
+                               add_assoc_string(subarray, "type", "PTR");
                        }
-                       add_assoc_string(*subarray, "target", pRec->Data.MX.pNameExchange);
+                       add_assoc_string(subarray, "target", pRec->Data.MX.pNameExchange);
                        break;
 
                /* Not available on windows, the query is possible but there is no DNS_HINFO_DATA structure */
@@ -208,12 +209,12 @@ static void php_parserr(PDNS_RECORD pRec, int type_to_fetch, int store, int raw,
                                zend_string *txt;
                                char *txt_dst;
                                long txt_len = 0;
-                               zval *entries;
+                               zval entries;
 
-                               add_assoc_string(*subarray, "type", "TXT");
+                               add_assoc_string(subarray, "type", "TXT");
+                               
+                               array_init(entries);
                                
-                               ZVAL_NEW_ARR(entries);
-
                                for (i = 0; i < count; i++) {
                                        txt_len += strlen(data_txt->pStringArray[i]) + 1;
                                }
@@ -223,12 +224,12 @@ static void php_parserr(PDNS_RECORD pRec, int type_to_fetch, int store, int raw,
                                for (i = 0; i < count; i++) {
                                        int len = strlen(data_txt->pStringArray[i]);
                                        memcpy(txt_dst, data_txt->pStringArray[i], len);
-                                       add_next_index_stringl(entries, data_txt->pStringArray[i], len);
+                                       add_next_index_stringl(&entries, data_txt->pStringArray[i], len);
                                        txt_dst += len;
                                }
-                               txt->len = txt_dst - txt->val;
-                               add_assoc_str(*subarray, "txt", txt);
-                               add_assoc_zval(*subarray, "entries", entries);
+                               tct->len = txt_dst - txt->val;
+                               add_assoc_str(subarray, "txt", txt);
+                               add_assoc_zval(subarray, "entries", &entries);
                        }
                        break;
 
@@ -236,15 +237,15 @@ static void php_parserr(PDNS_RECORD pRec, int type_to_fetch, int store, int raw,
                        {
                                DNS_SOA_DATA *data_soa = &pRec->Data.Soa;
 
-                               add_assoc_string(*subarray, "type", "SOA");
+                               add_assoc_string(subarray, "type", "SOA");
 
-                               add_assoc_string(*subarray, "mname", data_soa->pNamePrimaryServer);
-                               add_assoc_string(*subarray, "rname", data_soa->pNameAdministrator);
-                               add_assoc_long(*subarray, "serial", data_soa->dwSerialNo);
-                               add_assoc_long(*subarray, "refresh", data_soa->dwRefresh);
-                               add_assoc_long(*subarray, "retry", data_soa->dwRetry);
-                               add_assoc_long(*subarray, "expire", data_soa->dwExpire);
-                               add_assoc_long(*subarray, "minimum-ttl", data_soa->dwDefaultTtl);
+                               add_assoc_string(subarray, "mname", data_soa->pNamePrimaryServer);
+                               add_assoc_string(subarray, "rname", data_soa->pNameAdministrator);
+                               add_assoc_long(subarray, "serial", data_soa->dwSerialNo);
+                               add_assoc_long(subarray, "refresh", data_soa->dwRefresh);
+                               add_assoc_long(subarray, "retry", data_soa->dwRetry);
+                               add_assoc_long(subarray, "expire", data_soa->dwExpire);
+                               add_assoc_long(subarray, "minimum-ttl", data_soa->dwDefaultTtl);
                        }
                        break;
 
@@ -292,8 +293,8 @@ static void php_parserr(PDNS_RECORD pRec, int type_to_fetch, int store, int raw,
                                }
                                tp[0] = '\0';
 
-                               add_assoc_string(*subarray, "type", "AAAA");
-                               add_assoc_string(*subarray, "ipv6", buf);
+                               add_assoc_string(subarray, "type", "AAAA");
+                               add_assoc_string(subarray, "ipv6", buf);
                        }
                        break;
 
@@ -307,11 +308,11 @@ static void php_parserr(PDNS_RECORD pRec, int type_to_fetch, int store, int raw,
                        {
                                DNS_SRV_DATA *data_srv = &pRec->Data.Srv;
 
-                               add_assoc_string(*subarray, "type", "SRV");
-                               add_assoc_long(*subarray, "pri", data_srv->wPriority);
-                               add_assoc_long(*subarray, "weight", data_srv->wWeight);
-                               add_assoc_long(*subarray, "port", data_srv->wPort);
-                               add_assoc_string(*subarray, "target", data_srv->pNameTarget);
+                               add_assoc_string(subarray, "type", "SRV");
+                               add_assoc_long(subarray, "pri", data_srv->wPriority);
+                               add_assoc_long(subarray, "weight", data_srv->wWeight);
+                               add_assoc_long(subarray, "port", data_srv->wPort);
+                               add_assoc_string(subarray, "target", data_srv->pNameTarget);
                        }
                        break;
 
@@ -320,13 +321,13 @@ static void php_parserr(PDNS_RECORD pRec, int type_to_fetch, int store, int raw,
                        {
                                DNS_NAPTR_DATA * data_naptr = &pRec->Data.Naptr;
 
-                               add_assoc_string(*subarray, "type", "NAPTR");
-                               add_assoc_long(*subarray, "order", data_naptr->wOrder);
-                               add_assoc_long(*subarray, "pref", data_naptr->wPreference);
-                               add_assoc_string(*subarray, "flags", data_naptr->pFlags);
-                               add_assoc_string(*subarray, "services", data_naptr->pService);
-                               add_assoc_string(*subarray, "regex", data_naptr->pRegularExpression);
-                               add_assoc_string(*subarray, "replacement", data_naptr->pReplacement);
+                               add_assoc_string(subarray, "type", "NAPTR");
+                               add_assoc_long(subarray, "order", data_naptr->wOrder);
+                               add_assoc_long(subarray, "pref", data_naptr->wPreference);
+                               add_assoc_string(subarray, "flags", data_naptr->pFlags);
+                               add_assoc_string(subarray, "services", data_naptr->pService);
+                               add_assoc_string(subarray, "regex", data_naptr->pRegularExpression);
+                               add_assoc_string(subarray, "replacement", data_naptr->pReplacement);
                        }
                        break;
 #endif
@@ -334,7 +335,7 @@ static void php_parserr(PDNS_RECORD pRec, int type_to_fetch, int store, int raw,
                default:
                        /* unknown type */
                        zval_ptr_dtor(subarray);
-                       *subarray = NULL;
+                       ZVAL_UNDEF(subarray);
                        return;
        }
 
@@ -464,20 +465,20 @@ PHP_FUNCTION(dns_get_record)
 
                        for (pRec = pResult; pRec; pRec = pRec->pNext) {
                                DNS_SRV_DATA *srv = &pRec->Data.Srv;
-                               zval *retval = NULL;
+                               zval retval;
 
                                if (pRec->Flags.S.Section == DnsSectionAnswer) {
                                        php_parserr(pRec, type_to_fetch, store_results, raw, &retval);
-                                       if (retval != NULL && store_results) {
-                                               add_next_index_zval(return_value, retval);
+                                       if (!Z_ISUNDEF(retval) && store_results) {
+                                               add_next_index_zval(return_value, &retval);
                                        }
                                }
 
                                if (authns && pRec->Flags.S.Section == DnsSectionAuthority) {
 
                                        php_parserr(pRec, type_to_fetch, 1, raw, &retval);
-                                       if (retval != NULL) {
-                                               add_next_index_zval(authns, retval);
+                                       if (!Z_ISUNDEF(retval)) {
+                                               add_next_index_zval(authns, &retval);
                                        }
                                }
 
@@ -491,8 +492,8 @@ PHP_FUNCTION(dns_get_record)
 #endif
                                if (addtl && pRec->Flags.S.Section == DnsSectionAdditional) {
                                        php_parserr(pRec, type_to_fetch, 1, raw, &retval);
-                                       if (retval != NULL) {
-                                               add_next_index_zval(addtl, retval);
+                                       if (!Z_ISUNDEF(retval)) {
+                                               add_next_index_zval(addtl, &retval);
                                        }
                                }
                        }