Return-Path: X-Original-To: apmail-apr-dev-archive@www.apache.org Delivered-To: apmail-apr-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C1A5811107 for ; Mon, 14 Jul 2014 12:23:46 +0000 (UTC) Received: (qmail 1711 invoked by uid 500); 14 Jul 2014 12:23:46 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 1617 invoked by uid 500); 14 Jul 2014 12:23:46 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Id: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 1604 invoked by uid 99); 14 Jul 2014 12:23:46 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Jul 2014 12:23:46 +0000 X-ASF-Spam-Status: No, hits=0.7 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: 76.96.30.96 is neither permitted nor denied by domain of jim@jagunet.com) Received: from [76.96.30.96] (HELO qmta09.emeryville.ca.mail.comcast.net) (76.96.30.96) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Jul 2014 12:23:39 +0000 Received: from omta12.emeryville.ca.mail.comcast.net ([76.96.30.44]) by qmta09.emeryville.ca.mail.comcast.net with comcast id SCDa1o0020x6nqcA9CPJ69; Mon, 14 Jul 2014 12:23:18 +0000 Received: from [192.168.199.10] ([69.251.80.74]) by omta12.emeryville.ca.mail.comcast.net with comcast id SCPF1o00N1cCKD98YCPHft; Mon, 14 Jul 2014 12:23:18 +0000 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) Subject: Re: Skiplist improvements From: Jim Jagielski In-Reply-To: Date: Mon, 14 Jul 2014 08:23:15 -0400 Cc: apr Content-Transfer-Encoding: 7bit Message-Id: <169320FF-9808-4CA6-93F4-9E099B35F3FD@jaguNET.com> References: <581E0F48-0128-4B06-98EC-11D49DB5E507@jaguNET.com> <4E51F5E9-FA7B-40D4-A23D-A4B4B7F56C22@jaguNET.com> <580D5FC8-CF4C-4405-9111-546FB219E085@jaguNET.com> To: Yann Ylavic X-Mailer: Apple Mail (2.1878.6) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20140121; t=1405340598; bh=Au18seWBdhzCOX5/C0T28FJtjLwNtWqiVvwApRmnXeA=; h=Received:Received:Content-Type:Mime-Version:Subject:From:Date: Message-Id:To; b=IiwWcp2m8EuP9B0xucuORdmPBs5DaFn1cxPNr9urcYmgJPJIqk03XWNNe8aNkU+pu prbyzHU/TvXvnO+Bj7lMyl59KE0whgstWUfHIXYKQIlKVQe66b+d5UmoQnoSwMT/oY F8XiUx0x7dLyermdB0NLy4vjP86Bq79YFCyYdABbTyEVsrK6ETa2xc+dtjwahcAQXr qilB3vY5FL3dyjbzWDEZgb9tZyz8A9gqysUS8kg9nZ6iqJ1OmFusTAD2BTJE6VeFPX aGQFkZPMvHOfrIZcQt3F/NEk1Rxcwamnmz4AqhuqGPr9aQP9gErCDkMP8rjDnw+AU8 VdVDUjJtaCsYw== X-Virus-Checked: Checked by ClamAV on apache.org +1 On Jul 11, 2014, at 4:31 PM, Yann Ylavic wrote: > On Fri, Jul 11, 2014 at 10:22 PM, Yann Ylavic wrote: >> There also seem to be some doubtful code in apr_skiplist_remove_all(), >> addressed by the following patch : >> >> Index: tables/apr_skiplist.c >> =================================================================== >> --- tables/apr_skiplist.c (revision 1609655) >> +++ tables/apr_skiplist.c (working copy) >> @@ -591,16 +591,17 @@ APR_DECLARE(void) apr_skiplist_remove_all(apr_skip >> m = sl->bottom; >> while (m) { >> p = m->next; >> - if (p && myfree && p->data) >> - myfree(p->data); >> + if (myfree && m->data) >> + myfree(m->data); >> while (m) { >> u = m->up; >> - apr_skiplist_free(sl, p); >> + apr_skiplist_free(sl, m); >> m = u; >> } >> m = p; >> } >> sl->top = sl->bottom = NULL; >> + sl->topend = sl->bottomend = NULL; >> sl->height = 0; >> sl->size = 0; >> } >> >> Do you agree? > > Hmm, no, the initial myfree(p->data) is on purpose, bottom is a fake > node, the real first data are on bottom->next. > > Rather this patch : > > Index: tables/apr_skiplist.c > =================================================================== > --- tables/apr_skiplist.c (revision 1609655) > +++ tables/apr_skiplist.c (working copy) > @@ -595,12 +595,13 @@ APR_DECLARE(void) apr_skiplist_remove_all(apr_skip > myfree(p->data); > while (m) { > u = m->up; > - apr_skiplist_free(sl, p); > + apr_skiplist_free(sl, m); > m = u; > } > m = p; > } > sl->top = sl->bottom = NULL; > + sl->topend = sl->bottomend = NULL; > sl->height = 0; > sl->size = 0; > } > > to avoid multiple free() on the same node. > (NULLing topend and bottomend is a safety guard since they may be used > elsewhere without top or botton being checked).