lynx-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: lynx-dev Possible Bug in Lynx 2.8.5-dev.15


From: Ilya Zakharevich
Subject: Re: lynx-dev Possible Bug in Lynx 2.8.5-dev.15
Date: Sat, 3 May 2003 00:52:12 -0700
User-agent: Mutt/1.4i

On Fri, May 02, 2003 at 10:03:49PM -0700, Ilya Zakharevich wrote:
> Thomas Dickey wrote:
> 
>   The realloc is used to shrink storage requirements - IZ's comment
>   indicates it may be slow.  If it's too slow, we should drop that
>   chunk of code altogether.

Here is the fix.  I forgot that after itemcount--, the last item is
not what it was before the decrement.  ;-)

Sorry,
Ilya

--- ./src/TRSTable.c-as-sent    Sat Apr 12 21:42:56 2003
+++ ./src/TRSTable.c    Sat May  3 00:44:18 2003
@@ -1707,10 +1707,23 @@ PUBLIC int Stbl_trimFakeRows ARGS3(
        return 0;
     if ( prevrow->ended != ROW_ended_by_splitline) /* Lastrow non-fake */
        return 0;
-    /* XXXX should remove duplicate RESERVED stuff too */
     me->nrows--;
-    if (lastrow->cells && lastrow->allocated == 0) /* Moved to pool */
-       lastrow->cells = NULL;
+    /* prevrow is now the last row, so its cells should be realloc()able */
+    if (prevrow->cells && prevrow->allocated == 0) { /* Moved to pool */
+       int c = prevrow->ncells;
+       STable_cellinfo *p;
+
+       if (lastrow->allocated > c)     /* May have RESERVED info */
+           c = lastrow->allocated;
+       p = malloc(c * sizeof(STable_cellinfo));
+       memcpy(p, prevrow->cells, prevrow->ncells * sizeof(STable_cellinfo));
+       /* Copy back the possibly present RESERVED info.
+          XXXX remove duplicated RESERVED stuff from the followup rows too! */
+       memcpy(p + prevrow->ncells, lastrow->cells + prevrow->ncells,
+              (c - prevrow->ncells) * sizeof(STable_cellinfo));
+       prevrow->cells = p;     /* XXXX How would ride with RESERVED? */
+       prevrow->allocated = c;
+    }
     lastrow->ncells = 0;
     lastrow->content = 0;
     prevrow->ended = ROW_not_ended;    /* Give it new life */


; To UNSUBSCRIBE: Send "unsubscribe lynx-dev" to address@hidden

reply via email to

[Prev in Thread] Current Thread [Next in Thread]