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 59A8111AB1 for ; Sat, 21 Jun 2014 19:17:32 +0000 (UTC) Received: (qmail 83259 invoked by uid 500); 21 Jun 2014 19:17:31 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 83180 invoked by uid 500); 21 Jun 2014 19:17:31 -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 83170 invoked by uid 99); 21 Jun 2014 19:17:31 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 21 Jun 2014 19:17:31 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of trawick@gmail.com designates 209.85.217.175 as permitted sender) Received: from [209.85.217.175] (HELO mail-lb0-f175.google.com) (209.85.217.175) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 21 Jun 2014 19:17:29 +0000 Received: by mail-lb0-f175.google.com with SMTP id n15so423957lbi.34 for ; Sat, 21 Jun 2014 12:17:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=9/LwjBJ+l5NGsjrrjFsvyfOXQL+XX0CmqPqjlDL4Ia4=; b=SQzaoa2DtVBDRDCDrKAEYSHbn9VYQSTdVE6nQKhMqmy0p3ZxC9Gt9v3UWjBtozVNyZ 2VuLFL8n7ecVAFWmiM4LlpHnReidmElm8EW2hyzLE1j8ox3QJCT+1WyvsmNpZMLwG6FQ Q+rLkcrRIsD8a3WIKdimmjr/GZJRcQk+ghMMXQC/S2VBkC2eko1fg86Lskpw1pttAcvN 7DBw17Qy0P8c0tkPvpQvOCJUH/q7+AdMUw/a/naTNJb+ySVfjETk9y7gxovTwpTs/u4t s6uFnoiJthL13lPeqTPBJFEzLwICan5AULuNRv1HexQXUeu4zOT4CRhtm7Me5ovPaWv/ hgfQ== MIME-Version: 1.0 X-Received: by 10.112.63.65 with SMTP id e1mr2392022lbs.81.1403378224724; Sat, 21 Jun 2014 12:17:04 -0700 (PDT) Received: by 10.114.241.193 with HTTP; Sat, 21 Jun 2014 12:17:04 -0700 (PDT) In-Reply-To: <20140527142029.A762023888E4@eris.apache.org> References: <20140527142029.A762023888E4@eris.apache.org> Date: Sat, 21 Jun 2014 15:17:04 -0400 Message-ID: Subject: Re: svn commit: r1597797 - in /apr/apr/trunk: CHANGES include/apr_skiplist.h tables/apr_skiplist.c From: Jeff Trawick To: APR Developer List Content-Type: multipart/alternative; boundary=001a11c3b2c091ff7304fc5d7489 X-Virus-Checked: Checked by ClamAV on apache.org --001a11c3b2c091ff7304fc5d7489 Content-Type: text/plain; charset=UTF-8 On Tue, May 27, 2014 at 10:20 AM, wrote: > Author: jim > Date: Tue May 27 14:20:29 2014 > New Revision: 1597797 > > URL: http://svn.apache.org/r1597797 > Log: > apr_skiplist_add()... idea from yann > > Modified: > apr/apr/trunk/CHANGES > apr/apr/trunk/include/apr_skiplist.h > apr/apr/trunk/tables/apr_skiplist.c > > Modified: apr/apr/trunk/CHANGES > URL: > http://svn.apache.org/viewvc/apr/apr/trunk/CHANGES?rev=1597797&r1=1597796&r2=1597797&view=diff > > ============================================================================== > --- apr/apr/trunk/CHANGES [utf-8] (original) > +++ apr/apr/trunk/CHANGES [utf-8] Tue May 27 14:20:29 2014 > @@ -1,6 +1,8 @@ > -*- coding: utf-8 -*- > Changes for APR 2.0.0 > > + *) apr_skiplist: Add apr_skiplist_add() to support multiple values. > + > *) apr_allocator: Be less wasteful and don't return a memnode that is > much larger than what was requested. [Stefan Fuhrmann > ] > > Modified: apr/apr/trunk/include/apr_skiplist.h > URL: > http://svn.apache.org/viewvc/apr/apr/trunk/include/apr_skiplist.h?rev=1597797&r1=1597796&r2=1597797&view=diff > > ============================================================================== > --- apr/apr/trunk/include/apr_skiplist.h (original) > +++ apr/apr/trunk/include/apr_skiplist.h Tue May 27 14:20:29 2014 > @@ -180,11 +180,22 @@ APR_DECLARE(apr_skiplistnode *) apr_skip > void *data, > apr_skiplist_compare comp); > > /** > + * Add an element into the skip list using the existing comparison > function. > + * @param sl The skip list > + * @param data The element to insert > + * @remark If no comparison function has been set for the skip list, the > element > + * will not be inserted and NULL will be returned. This allows for > multiple > + * values to be added to the skiplist. To replace values, use > apr_skiplist_insert(). > + */ > +APR_DECLARE(apr_skiplistnode *) apr_skiplist_add(apr_skiplist* sl, void > *data); > + > +/** > * Insert an element into the skip list using the existing comparison > function. > * @param sl The skip list > * @param data The element to insert > * @remark If no comparison function has been set for the skip list, the > element > - * will not be inserted and NULL will be returned. > + * will not be inserted and NULL will be returned. Previous values will > + * be over-written. Use apr_skiplist_add() to allow multiple values. > */ > APR_DECLARE(apr_skiplistnode *) apr_skiplist_insert(apr_skiplist* sl, > void *data); > > > Modified: apr/apr/trunk/tables/apr_skiplist.c > URL: > http://svn.apache.org/viewvc/apr/apr/trunk/tables/apr_skiplist.c?rev=1597797&r1=1597796&r2=1597797&view=diff > > ============================================================================== > --- apr/apr/trunk/tables/apr_skiplist.c (original) > +++ apr/apr/trunk/tables/apr_skiplist.c Tue May 27 14:20:29 2014 > @@ -339,16 +339,8 @@ APR_DECLARE(void *) apr_skiplist_previou > return (*iter) ? ((*iter)->data) : NULL; > } > > -APR_DECLARE(apr_skiplistnode *) apr_skiplist_insert(apr_skiplist *sl, > void *data) > -{ > - if (!sl->compare) { > - return 0; > - } > - return apr_skiplist_insert_compare(sl, data, sl->compare); > -} > - > -APR_DECLARE(apr_skiplistnode *) apr_skiplist_insert_compare(apr_skiplist > *sl, void *data, > - apr_skiplist_compare comp) > +static apr_skiplistnode *insert_compare(apr_skiplist *sl, void *data, > + apr_skiplist_compare comp, int > replace) > { > apr_skiplistnode *m, *p, *tmp, *ret = NULL, **stack; > int nh = 1, ch, stacki; > @@ -406,11 +398,11 @@ APR_DECLARE(apr_skiplistnode *) apr_skip > if (m->next) { > compared = comp(data, m->next->data); > } > - if (compared == 0) { > + if (compared == 0 && replace) { > free(stack); /* OK. was malloc'ed */ > return 0; > } > - if ((m->next == NULL) || (compared < 0)) { > + if ( (compared < 0) || (replace && (m->next == NULL)) ) { > if (ch <= nh) { > /* push on stack */ > stack[stacki++] = m; > @@ -470,6 +462,34 @@ APR_DECLARE(apr_skiplistnode *) apr_skip > return ret; > } > > +APR_DECLARE(apr_skiplistnode *) apr_skiplist_insert(apr_skiplist *sl, > void *data) > +{ > + if (!sl->compare) { > + return 0; > + } > + return insert_compare(sl, data, sl->compare, 1); > +} > + > +APR_DECLARE(apr_skiplistnode *) apr_skiplist_add_compare(apr_skiplist > *sl, void *data, > + apr_skiplist_compare comp) > no prototype, not called > +{ > + return insert_compare(sl, data, comp, 0); > +} > + > +APR_DECLARE(apr_skiplistnode *) apr_skiplist_add(apr_skiplist *sl, void > *data) > +{ > + if (!sl->compare) { > + return 0; > + } > + return insert_compare(sl, data, sl->compare, 0); > +} > + > +APR_DECLARE(apr_skiplistnode *) apr_skiplist_insert_compare(apr_skiplist > *sl, void *data, > + apr_skiplist_compare comp) > +{ > + return insert_compare(sl, data, comp, 1); > +} > + > APR_DECLARE(int) apr_skiplist_remove(apr_skiplist *sl, void *data, > apr_skiplist_freefunc myfree) > { > if (!sl->compare) { > > > -- Born in Roswell... married an alien... http://emptyhammock.com/ http://edjective.org/ --001a11c3b2c091ff7304fc5d7489 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On T= ue, May 27, 2014 at 10:20 AM, <jim@apache.org> wrote:
Author: jim
Date: Tue May 27 14:20:29 2014
New Revision: 1597797

URL: http://sv= n.apache.org/r1597797
Log:
apr_skiplist_add()... idea from yann

Modified:
=C2=A0 =C2=A0 apr/apr/trunk/CHANGES
=C2=A0 =C2=A0 apr/apr/trunk/include/apr_skiplist.h
=C2=A0 =C2=A0 apr/apr/trunk/tables/apr_skiplist.c

Modified: apr/apr/trunk/CHANGES
URL: = http://svn.apache.org/viewvc/apr/apr/trunk/CHANGES?rev=3D1597797&r1=3D1= 597796&r2=3D1597797&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D
--- apr/apr/trunk/CHANGES [utf-8] (original)
+++ apr/apr/trunk/CHANGES [utf-8] Tue May 27 14:20:29 2014
@@ -1,6 +1,8 @@
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 -*- coding: utf-8 -*-
=C2=A0Changes for APR 2.0.0

+ =C2=A0*) apr_skiplist: Add apr_skiplist_add() to support multiple values.=
+
=C2=A0 =C2=A0*) apr_allocator: Be less wasteful and don't return a memn= ode that is
=C2=A0 =C2=A0 =C2=A0 much larger than what was requested. [Stefan Fuhrmann<= br> =C2=A0 =C2=A0 =C2=A0 <stefan fuhrmann wandisco com>]

Modified: apr/apr/trunk/include/apr_skiplist.h
URL: http://svn.apache.org/viewvc/apr/apr/trunk/include/apr_skipl= ist.h?rev=3D1597797&r1=3D1597796&r2=3D1597797&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D
--- apr/apr/trunk/include/apr_skiplist.h (original)
+++ apr/apr/trunk/include/apr_skiplist.h Tue May 27 14:20:29 2014
@@ -180,11 +180,22 @@ APR_DECLARE(apr_skiplistnode *) apr_skip
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0void *data, apr_skiplist_compare comp);

=C2=A0/**
+ * Add an element into the skip list using the existing comparison functio= n.
+ * @param sl The skip list
+ * @param data The element to insert
+ * @remark If no comparison function has been set for the skip list, the e= lement
+ * will not be inserted and NULL will be returned. This allows for multipl= e
+ * values to be added to the skiplist. To replace values, use apr_skiplist= _insert().
+ */
+APR_DECLARE(apr_skiplistnode *) apr_skiplist_add(apr_skiplist* sl, void *d= ata);
+
+/**
=C2=A0 * Insert an element into the skip list using the existing comparison= function.
=C2=A0 * @param sl The skip list
=C2=A0 * @param data The element to insert
=C2=A0 * @remark If no comparison function has been set for the skip list, = the element
- * will not be inserted and NULL will be returned.
+ * will not be inserted and NULL will be returned. Previous values will + * be over-written. Use apr_skiplist_add() to allow multiple values.
=C2=A0 */
=C2=A0APR_DECLARE(apr_skiplistnode *) apr_skiplist_insert(apr_skiplist* sl,= void *data);


Modified: apr/apr/trunk/tables/apr_skiplist.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/tables/apr_skiplis= t.c?rev=3D1597797&r1=3D1597796&r2=3D1597797&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D
--- apr/apr/trunk/tables/apr_skiplist.c (original)
+++ apr/apr/trunk/tables/apr_skiplist.c Tue May 27 14:20:29 2014
@@ -339,16 +339,8 @@ APR_DECLARE(void *) apr_skiplist_previou
=C2=A0 =C2=A0 =C2=A0return (*iter) ? ((*iter)->data) : NULL;
=C2=A0}

-APR_DECLARE(apr_skiplistnode *) apr_skiplist_insert(apr_skiplist *sl, void= *data)
-{
- =C2=A0 =C2=A0if (!sl->compare) {
- =C2=A0 =C2=A0 =C2=A0 =C2=A0return 0;
- =C2=A0 =C2=A0}
- =C2=A0 =C2=A0return apr_skiplist_insert_compare(sl, data, sl->compare)= ;
-}
-
-APR_DECLARE(apr_skiplistnode *) apr_skiplist_insert_compare(apr_skiplist *= sl, void *data,
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0apr_skiplist_com= pare comp)
+static apr_skiplistnode *insert_compare(apr_skiplist *sl, void *data,
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0apr_skipl= ist_compare comp, int replace)
=C2=A0{
=C2=A0 =C2=A0 =C2=A0apr_skiplistnode *m, *p, *tmp, *ret =3D NULL, **stack;<= br> =C2=A0 =C2=A0 =C2=A0int nh =3D 1, ch, stacki;
@@ -406,11 +398,11 @@ APR_DECLARE(apr_skiplistnode *) apr_skip
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (m->next) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0compared =3D comp(data, m-&= gt;next->data);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
- =C2=A0 =C2=A0 =C2=A0 =C2=A0if (compared =3D=3D 0) {
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0if (compared =3D=3D 0 && replace) { =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0free(stack); =C2=A0 =C2=A0/= * OK. was malloc'ed */
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return 0;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
- =C2=A0 =C2=A0 =C2=A0 =C2=A0if ((m->next =3D=3D NULL) || (compared <= 0)) {
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0if ( (compared < 0) || (replace && = (m->next =3D=3D NULL)) ) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (ch <=3D nh) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/* push on st= ack */
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0stack[stacki+= +] =3D m;
@@ -470,6 +462,34 @@ APR_DECLARE(apr_skiplistnode *) apr_skip
=C2=A0 =C2=A0 =C2=A0return ret;
=C2=A0}

+APR_DECLARE(apr_skiplistnode *) apr_skiplist_insert(apr_skiplist *sl, void= *data)
+{
+ =C2=A0 =C2=A0if (!sl->compare) {
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0return 0;
+ =C2=A0 =C2=A0}
+ =C2=A0 =C2=A0return insert_compare(sl, data, sl->compare, 1);
+}
+
+APR_DECLARE(apr_skiplistnode *) apr_skiplist_add_compare(apr_skiplist *sl,= void *data,
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0apr_skiplist_com= pare comp)

no prototype, not called
=C2=A0
+{
+ =C2=A0 =C2=A0return insert_compare(sl, data, comp, 0);
+}
+
+APR_DECLARE(apr_skiplistnode *) apr_skiplist_add(apr_skiplist *sl, void *d= ata)
+{
+ =C2=A0 =C2=A0if (!sl->compare) {
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0return 0;
+ =C2=A0 =C2=A0}
+ =C2=A0 =C2=A0return insert_compare(sl, data, sl->compare, 0);
+}
+
+APR_DECLARE(apr_skiplistnode *) apr_skiplist_insert_compare(apr_skiplist *= sl, void *data,
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0apr_skiplist_com= pare comp)
+{
+ =C2=A0 =C2=A0return insert_compare(sl, data, comp, 1);
+}
+
=C2=A0APR_DECLARE(int) apr_skiplist_remove(apr_skiplist *sl, void *data, ap= r_skiplist_freefunc myfree)
=C2=A0{
=C2=A0 =C2=A0 =C2=A0if (!sl->compare) {





--
Born in Roswell... married an alien...
http://emptyhammock.com/

--001a11c3b2c091ff7304fc5d7489--