dotgnu-pnet-commits
[Top][All Lists]
Advanced

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

[dotgnu-pnet-commits] pnetlib ./ChangeLog runtime/System/Collections/...


From: Heiko Weiss
Subject: [dotgnu-pnet-commits] pnetlib ./ChangeLog runtime/System/Collections/...
Date: Thu, 13 Apr 2006 15:18:09 +0000

CVSROOT:        /sources/dotgnu-pnet
Module name:    pnetlib
Branch:         
Changes by:     Heiko Weiss <address@hidden>    06/04/13 15:18:08

Modified files:
        .              : ChangeLog 
        runtime/System/Collections: ArrayList.cs Queue.cs SortedList.cs 
        runtime/System/Private/NumberFormat: CustomFormatter.cs 
                                             Formatter.cs 
                                             ScientificFormatter.cs 
                                             GeneralFormatter.cs 

Log message:
        ArrayList Queue SortedList : fixed memory leak.
        Formatters: fixed formatting floats.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/ChangeLog.diff?tr1=1.2382&tr2=1.2383&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/runtime/System/Collections/ArrayList.cs.diff?tr1=1.20&tr2=1.21&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/runtime/System/Collections/Queue.cs.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/runtime/System/Collections/SortedList.cs.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/runtime/System/Private/NumberFormat/CustomFormatter.cs.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/runtime/System/Private/NumberFormat/Formatter.cs.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/runtime/System/Private/NumberFormat/ScientificFormatter.cs.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/runtime/System/Private/NumberFormat/GeneralFormatter.cs.diff?tr1=1.8&tr2=1.9&r1=text&r2=text

Patches:
Index: pnetlib/ChangeLog
diff -u pnetlib/ChangeLog:1.2382 pnetlib/ChangeLog:1.2383
--- pnetlib/ChangeLog:1.2382    Thu Apr 13 06:11:19 2006
+++ pnetlib/ChangeLog   Thu Apr 13 15:18:08 2006
@@ -1,5 +1,15 @@
 2006-04-13  Heiko Weiss  <address@hidden>
 
+       * pnetlib/runtime/System/Collections/ArrayList.cs: fixed memory leak.
+       * pnetlib/runtime/System/Collections/Queue.cs: fixed memory leak.
+       * pnetlib/runtime/System/Collections/SortedList.cs: fixed memory leak.
+       * pnetlib/runtime/System/Private/NumberFormat/CustomFormatter.cs: fixed 
bug with formatting floats.
+       * pnetlib/runtime/System/Private/NumberFormat/Formatter.cs: fixed bug 
with formatting floats.
+       * pnetlib/runtime/System/Private/NumberFormat/ScientificFormatter.cs: 
fixed bug with formatting floats.
+       * pnetlib/runtime/System/Private/NumberFormat/GeneralFormatter.cs: 
fixed bug with formatting floats.
+
+2006-04-13  Heiko Weiss  <address@hidden>
+
        * runtime/System/Collections/Stack.cs: Fixed a memory leak in 
Stack.Pop() and Stack.Clear().
 
 2006-04-12  Radek Polak  <address@hidden>
Index: pnetlib/runtime/System/Collections/ArrayList.cs
diff -u pnetlib/runtime/System/Collections/ArrayList.cs:1.20 
pnetlib/runtime/System/Collections/ArrayList.cs:1.21
--- pnetlib/runtime/System/Collections/ArrayList.cs:1.20        Tue Feb 21 
10:04:21 2006
+++ pnetlib/runtime/System/Collections/ArrayList.cs     Thu Apr 13 15:18:08 2006
@@ -97,6 +97,7 @@
                                        while(posn >= index)
                                        {
                                                store[posn + n] = store[posn];
+                                               store[posn] = null; // Brubbel: 
set the new free entry to zero
                                                --posn;
                                        }
                                }
@@ -127,9 +128,15 @@
        // This modifies "count".
        private void Delete(int n, int index)
                        {
-                               while((index + n) < count)
+                               while((index + n) <= count) // brubbel : must 
be <=
                                {
-                                       store[index] = store[index + n];
+                                       if( (index + n) == count ) {
+                                               store[index] = null;
+                                       }
+                                       else {
+                                               store[index] = store[index + n];
+                                               store[index + n] = null; // 
brubbel : set the new free entries to zero to avoid mem leaks
+                                       }
                                        ++index;
                                }
                                count -= n;
Index: pnetlib/runtime/System/Collections/Queue.cs
diff -u pnetlib/runtime/System/Collections/Queue.cs:1.6 
pnetlib/runtime/System/Collections/Queue.cs:1.7
--- pnetlib/runtime/System/Collections/Queue.cs:1.6     Fri Jan 30 06:07:38 2004
+++ pnetlib/runtime/System/Collections/Queue.cs Thu Apr 13 15:18:08 2006
@@ -172,6 +172,7 @@
        // Clear the contents of this queue.
        public virtual void Clear()
                        {
+                               Array.Clear(items, 0, items.Length); // clear 
references of objects
                                add = 0;
                                remove = 0;
                                size = 0;
@@ -209,6 +210,7 @@
                                if(size > 0)
                                {
                                        Object value = items[remove];
+                                       items[remove] = null;   // set to null 
to release the handle
                                        remove = (remove + 1) % items.Length;
                                        --size;
                                        ++generation;
Index: pnetlib/runtime/System/Collections/SortedList.cs
diff -u pnetlib/runtime/System/Collections/SortedList.cs:1.6 
pnetlib/runtime/System/Collections/SortedList.cs:1.7
--- pnetlib/runtime/System/Collections/SortedList.cs:1.6        Fri Oct  7 
11:58:26 2005
+++ pnetlib/runtime/System/Collections/SortedList.cs    Thu Apr 13 15:18:08 2006
@@ -178,6 +178,10 @@
                                        keys[posn]   = keys[posn + 1];
                                        values[posn] = values[posn + 1];
                                }
+                               // remove last reference to avoid memory leak
+                               keys[posn]   = null;
+                               values[posn] = null;
+                               
                                --count;
                                ++generation;
                        }
@@ -198,6 +202,8 @@
                        }
        public virtual void Clear()
                        {
+                               Array.Clear( values, 0, values.Length ); // 
clear the array to release references
+                               Array.Clear( keys, 0, keys.Length ); // clear 
the array to release references
                                count = 0;
                                ++generation;
                        }
Index: pnetlib/runtime/System/Private/NumberFormat/CustomFormatter.cs
diff -u pnetlib/runtime/System/Private/NumberFormat/CustomFormatter.cs:1.4 
pnetlib/runtime/System/Private/NumberFormat/CustomFormatter.cs:1.5
--- pnetlib/runtime/System/Private/NumberFormat/CustomFormatter.cs:1.4  Tue Apr 
15 07:27:54 2003
+++ pnetlib/runtime/System/Private/NumberFormat/CustomFormatter.cs      Thu Apr 
13 15:18:08 2006
@@ -326,7 +326,8 @@
        private string FormatScientific(double d, string format, int sign,
                                                                                
                        IFormatProvider provider)
        {
-               int exponent = (int)Math.Floor(Math.Log10(d));
+               //int exponent = (int)Math.Floor(Math.Log10(d));
+               int exponent = Formatter.GetExponent( d );
                double mantissa = d/Math.Pow(10,exponent);
 
                int i = ScientificStart(format);
Index: pnetlib/runtime/System/Private/NumberFormat/Formatter.cs
diff -u pnetlib/runtime/System/Private/NumberFormat/Formatter.cs:1.12 
pnetlib/runtime/System/Private/NumberFormat/Formatter.cs:1.13
--- pnetlib/runtime/System/Private/NumberFormat/Formatter.cs:1.12       Wed Dec 
 7 09:05:53 2005
+++ pnetlib/runtime/System/Private/NumberFormat/Formatter.cs    Thu Apr 13 
15:18:08 2006
@@ -436,12 +436,42 @@
                return ret.ToString();
        }
 
+       internal static int GetExponent( double value ) {
+               // return (int)Math.Floor(Math.Log10(Math.Abs(value)));
+               /*
+                       Note:
+                       if value is a value like 
99.9999999999999999999999999999998
+                       Math.Log10(value) would return 2.0
+                       but it should return 1.0
+                       so the exponent would be one to big.
+                       So the Method below is now used to calculate the 
exponent.
+               */
+               if( value == 0.0 ) return 0;
+               
+               value = Math.Abs(value);
+               int exponent = 0;
+               if( value >= 1.0 ) {
+                       while( value >= 10.0 ) {
+                               exponent++;
+                               value /= 10.0;
+                       } 
+               }
+               else {
+                       while( value <= 1.0 ) {
+                               exponent--;
+                               value *= 10.0;
+                       } 
+               }
+               return exponent;
+       }
+       
        static protected string FormatFloat(double value, int precision)
        {
                if (value == 0.0) return ".";
 
                //  
-               int exponent = (int)Math.Floor(Math.Log10(Math.Abs(value)));
+               //int exponent = (int)Math.Floor(Math.Log10(Math.Abs(value)));
+               int exponent = Formatter.GetExponent( value );
                double work = value * Math.Pow(10, 16 - exponent);
                
                //
Index: pnetlib/runtime/System/Private/NumberFormat/GeneralFormatter.cs
diff -u pnetlib/runtime/System/Private/NumberFormat/GeneralFormatter.cs:1.8 
pnetlib/runtime/System/Private/NumberFormat/GeneralFormatter.cs:1.9
--- pnetlib/runtime/System/Private/NumberFormat/GeneralFormatter.cs:1.8 Tue Apr 
15 07:27:54 2003
+++ pnetlib/runtime/System/Private/NumberFormat/GeneralFormatter.cs     Thu Apr 
13 15:18:08 2006
@@ -100,7 +100,8 @@
                }
                else
                {
-                       exponent = (int) 
Math.Floor(Math.Log10(Math.Abs(OToDouble(o))));
+                       //exponent = (int) 
Math.Floor(Math.Log10(Math.Abs(OToDouble(o))));
+                       exponent = Formatter.GetExponent( OToDouble(o) );
                }
 #else
                // Determine the exponent without using floating-point.
Index: pnetlib/runtime/System/Private/NumberFormat/ScientificFormatter.cs
diff -u pnetlib/runtime/System/Private/NumberFormat/ScientificFormatter.cs:1.6 
pnetlib/runtime/System/Private/NumberFormat/ScientificFormatter.cs:1.7
--- pnetlib/runtime/System/Private/NumberFormat/ScientificFormatter.cs:1.6      
Tue Apr 15 07:27:54 2003
+++ pnetlib/runtime/System/Private/NumberFormat/ScientificFormatter.cs  Thu Apr 
13 15:18:08 2006
@@ -78,7 +78,8 @@
                }
                else
                {
-                       exponent = (int) Math.Floor(Math.Log10(value));
+                       //exponent = (int) Math.Floor(Math.Log10(value));
+                       exponent = Formatter.GetExponent( value );
                        mantissa = value / Math.Pow(10, exponent);
                }
 




reply via email to

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