Return-Path: Delivered-To: apmail-httpd-modules-dev-archive@minotaur.apache.org Received: (qmail 71684 invoked from network); 26 Jan 2011 16:03:12 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 26 Jan 2011 16:03:12 -0000 Received: (qmail 56245 invoked by uid 500); 26 Jan 2011 16:03:12 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 55971 invoked by uid 500); 26 Jan 2011 16:03:09 -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 55957 invoked by uid 99); 26 Jan 2011 16:03:08 -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 16:03:08 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of sorinm@gmail.com designates 209.85.216.45 as permitted sender) Received: from [209.85.216.45] (HELO mail-qw0-f45.google.com) (209.85.216.45) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Jan 2011 16:03:01 +0000 Received: by qwk4 with SMTP id 4so1126793qwk.18 for ; Wed, 26 Jan 2011 08:02:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=lcCCR9KercbtVdM80V2a1QTULHi2GE7CWaBmTiWM8qk=; b=WBNtxolLidu/hBPLXMIqTrAABZrh31eFVb29vBKOhc51fNc6k1AmqJgbDu8I2yZ3hN YVnh/ee1yJ4FPEQUiNtmL93fwKUBui11AtvO1eUUXi5PEt0XnosU5bJcma/z+B3he3g3 powvuMe276hoo8Aujgk6Z6AcOyPyI8GSID5JM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=RN7IV43Wd2RfHr+xMWcBGaNq+afsTyQVg/7B/Ifi0M7ajg3quz0d6oCdWEH0A2RNZZ 13eSUNdnPOysuM4gqJrrpDCnKovzcw1K1MWvrFWB5q0rJU2pbrQUjbwdwnSX5F+2qMnn KYIcy+vOE6tPq9nwlBuuYHAC57oDIV2w2WICU= MIME-Version: 1.0 Received: by 10.224.19.142 with SMTP id a14mr587088qab.194.1296057760654; Wed, 26 Jan 2011 08:02:40 -0800 (PST) Received: by 10.224.19.203 with HTTP; Wed, 26 Jan 2011 08:02:40 -0800 (PST) In-Reply-To: <4D403D90.6020105@simonecaruso.com> References: <4D403D90.6020105@simonecaruso.com> Date: Wed, 26 Jan 2011 17:02:40 +0100 Message-ID: Subject: Re: I don't understand apr_array_push From: Sorin Manolache To: modules-dev@httpd.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org In my opinion the problem is here: alias =3D (alias_t *)&reqc->aliases->elts[k]; Try alias =3D ((alias_t *)reqc->aliases->elts)[k]; S On Wed, Jan 26, 2011 at 16:28, Simone Caruso wrote: > Hi list, > > i can't understand the reason i can't read from an "apr array", my code i= s > like this: > > =A0 =A0 =A0 =A0//The 2 arrays, now working on reqc->aliases > =A0 =A0 =A0 =A0reqc->aliases =3D (apr_array_header_t *)apr_array_make(r->= pool, 5, > sizeof(alias_t)); > =A0 =A0 =A0 =A0reqc->redirects =3D (apr_array_header_t *)apr_array_make(r= ->pool, 5, > sizeof(alias_t)); > > =A0 =A0 =A0 =A0while (attributes[i]) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (strcasecmp (attributes= [i], "apacheServerName") =3D=3D > 0) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0reqc->name= =3D apr_pstrdup (r->pool, vals[i]); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} else if (strcasecmp (att= ributes[i], > "apacheServerAdmin") =3D=3D 0) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0reqc->admi= n =3D apr_pstrdup (r->pool, vals[i]); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} else if (strcasecmp (att= ributes[i], > "apacheDocumentRoot") =3D=3D 0) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0reqc->docr= oot =3D apr_pstrdup (r->pool, > vals[i]); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} else if (strcasecmp (att= ributes[i], > "apacheScriptAlias") =3D=3D 0) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0cur =3D st= rstr(vals[i], " "); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if(cur - v= als[i] > 1 ){ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0tmp =3D apr_palloc(r->pool, > sizeof(char)*strlen(vals[i])); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0strcpy(tmp, vals[i]); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0tok =3D NULL; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0alias =3D > apr_array_push(reqc->aliases);//HERE THE PUSH > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0alias->src =3D apr_strtok((char *)tmp , > " ", &tok); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0alias->dst =3D apr_strtok(NULL, " ", > &tok); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0alias->iscgi =3D 1; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0isalias =3D 1; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}else{ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0ap_log_rerror(APLOG_MARK, > APLOG_DEBUG|APLOG_NOERRNO, 0, r, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0"[mod_vhost_ldap_ng.c]: Wrong > apacheScriptAlias paramter: %s", vals[i]); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} else if (strcasecmp (att= ributes[i], "apacheAlias") > =3D=3D 0) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0cur =3D st= rstr(vals[i], " "); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if(cur - v= als[i] > 1 ){ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0tmp =3D apr_palloc(r->pool, > sizeof(char)*strlen(vals[i])); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0strcpy(tmp, vals[i]); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0tok =3D NULL; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0alias =3D > apr_array_push(reqc->aliases); //HERE THE PUSH > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0alias->src =3D apr_strtok((char > *)vals[i] , " ", &tok); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0alias->dst =3D apr_strtok(NULL, " ", > &tok); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0alias->iscgi =3D 0; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0isalias =3D 1; > > > Now i need to read the array (i read mod_alias.c): > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0for(k =3D 0; k < reqc->aliases->nelts ; k+= +){ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0alias =3D (alias_t *)&reqc= ->aliases->elts[k]; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0isalias =3D alias_matches(= r->uri, alias->src); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if(isalias > 0) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0break; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > > > I don't understand why, when k=3D2, alias structure is filled with wrong > addresses: > > (gdb) > 658 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 isalias =3D a= lias_matches(r->uri, alias->src); > (gdb) > > Program received signal SIGSEGV, Segmentation fault. > 0x00007fc350e6784f in alias_matches (uri=3D0x94f820 "/", > =A0 =A0alias_fakename=3D0xda000000000094ff
bounds>) > > > I tried a for like this without success (like mod_alias.c): > for(k =3D 0; k < reqc->aliases->nelts -1 ; ++k){ > > > Any idea? > thanks! > > > -- > Simone Caruso > IT Consultant > +39 349 65 90 805 > p.iva: 03045250838 >