Return-Path: Delivered-To: apmail-httpd-modules-dev-archive@minotaur.apache.org Received: (qmail 58447 invoked from network); 26 Jan 2011 15:28:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 26 Jan 2011 15:28:50 -0000 Received: (qmail 79492 invoked by uid 500); 26 Jan 2011 15:28:50 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 79211 invoked by uid 500); 26 Jan 2011 15:28:47 -0000 Mailing-List: contact modules-dev-help@httpd.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: modules-dev@httpd.apache.org Delivered-To: mailing list modules-dev@httpd.apache.org Received: (qmail 79198 invoked by uid 99); 26 Jan 2011 15:28:46 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Jan 2011 15:28:46 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=10.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [94.23.41.186] (HELO mail.ardeek.com) (94.23.41.186) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Jan 2011 15:28:37 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.ardeek.com (Postfix) with ESMTP id 6AC9C2B260 for ; Wed, 26 Jan 2011 16:28:17 +0100 (CET) Received: from mail.ardeek.com ([127.0.0.1]) by localhost (sheldon.ardeek.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3dlGQS+swIfU for ; Wed, 26 Jan 2011 16:28:17 +0100 (CET) Received: from [192.168.1.22] (unknown [151.62.226.120]) by mail.ardeek.com (Postfix) with ESMTPA id BE77B2AFF9 for ; Wed, 26 Jan 2011 16:28:16 +0100 (CET) Message-ID: <4D403D90.6020105@simonecaruso.com> Date: Wed, 26 Jan 2011 16:28:16 +0100 From: Simone Caruso User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101207 Lightning/1.0b2 Thunderbird/3.1.7 MIME-Version: 1.0 To: modules-dev@httpd.apache.org Subject: I don't understand apr_array_push Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Hi list, i can't understand the reason i can't read from an "apr array", my code is like this: //The 2 arrays, now working on reqc->aliases reqc->aliases = (apr_array_header_t *)apr_array_make(r->pool, 5, sizeof(alias_t)); reqc->redirects = (apr_array_header_t *)apr_array_make(r->pool, 5, sizeof(alias_t)); while (attributes[i]) { if (strcasecmp (attributes[i], "apacheServerName") == 0) { reqc->name = apr_pstrdup (r->pool, vals[i]); } else if (strcasecmp (attributes[i], "apacheServerAdmin") == 0) { reqc->admin = apr_pstrdup (r->pool, vals[i]); } else if (strcasecmp (attributes[i], "apacheDocumentRoot") == 0) { reqc->docroot = apr_pstrdup (r->pool, vals[i]); } else if (strcasecmp (attributes[i], "apacheScriptAlias") == 0) { cur = strstr(vals[i], " "); if(cur - vals[i] > 1 ){ tmp = apr_palloc(r->pool, sizeof(char)*strlen(vals[i])); strcpy(tmp, vals[i]); tok = NULL; alias = apr_array_push(reqc->aliases);//HERE THE PUSH alias->src = apr_strtok((char *)tmp , " ", &tok); alias->dst = apr_strtok(NULL, " ", &tok); alias->iscgi = 1; isalias = 1; }else{ ap_log_rerror(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r, "[mod_vhost_ldap_ng.c]: Wrong apacheScriptAlias paramter: %s", vals[i]); } } else if (strcasecmp (attributes[i], "apacheAlias") == 0) { cur = strstr(vals[i], " "); if(cur - vals[i] > 1 ){ tmp = apr_palloc(r->pool, sizeof(char)*strlen(vals[i])); strcpy(tmp, vals[i]); tok = NULL; alias = apr_array_push(reqc->aliases); //HERE THE PUSH alias->src = apr_strtok((char *)vals[i] , " ", &tok); alias->dst = apr_strtok(NULL, " ", &tok); alias->iscgi = 0; isalias = 1; Now i need to read the array (i read mod_alias.c): for(k = 0; k < reqc->aliases->nelts ; k++){ alias = (alias_t *)&reqc->aliases->elts[k]; isalias = alias_matches(r->uri, alias->src); if(isalias > 0) break; } I don't understand why, when k=2, alias structure is filled with wrong addresses: (gdb) 658 isalias = alias_matches(r->uri, alias->src); (gdb) Program received signal SIGSEGV, Segmentation fault. 0x00007fc350e6784f in alias_matches (uri=0x94f820 "/", alias_fakename=0xda000000000094ff
) I tried a for like this without success (like mod_alias.c): for(k = 0; k < reqc->aliases->nelts -1 ; ++k){ Any idea? thanks! -- Simone Caruso IT Consultant +39 349 65 90 805 p.iva: 03045250838