Low Zero Limbs

LingWitt@insightbb.com LingWitt@insightbb.com
Mon, 23 Jun 2003 20:21:36 -0400


--Apple-Mail-2-797485669
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=US-ASCII;
	format=flowed

Two questions:

On Monday, Jun 23, 2003, at 18:53 America/New_York, Kevin Ryde wrote:

> LingWitt@insightbb.com writes:
>>
>>     f->_mp_size = sizeNew;
>
> You need to move the retained limbs down to the start of f->_mp_d too.

Do you mean _mp_d should be set to the first nonzero limb:
Will this cause a leak?

unsigned int stripLowZeroLimbs(mpf_ptr f)
{
     int		sizeNew		= f->_mp_size;
     mp_limb_t*	limbs		= f->_mp_d;
     mp_limb_t*	limb		= 0;

     while (*(limb = limbs++) == 0 && sizeNew > 1)
     {
         //free(limb);
         sizeNew--;
     }

     f->_mp_size = sizeNew;
     f->_mp_d = limb;

     return f->_mp_size - sizeNew;
}
--Apple-Mail-2-797485669
Content-Transfer-Encoding: 7bit
Content-Type: text/enriched;
	charset=US-ASCII

Two questions:


On Monday, Jun 23, 2003, at 18:53 America/New_York, Kevin Ryde wrote:


<excerpt>LingWitt@insightbb.com writes:

<excerpt>

    f->_mp_size = sizeNew;

</excerpt>

You need to move the retained limbs down to the start of f->_mp_d too.

</excerpt>

Do you mean _mp_d should be set to the first nonzero limb:

Will this cause a leak?


<fixed><color><param>7674,0F0D,504E</param>unsigned</color> int
stripLowZeroLimbs(mpf_ptr f)

{

    <color><param>7674,0F0D,504E</param>int</color>		sizeNew		=
f->_mp_size;

    mp_limb_t*	limbs		= f->_mp_d;

    mp_limb_t*	limb		= <color><param>0000,0000,FFFD</param>0</color>;

    

    <color><param>7674,0F0D,504E</param>while</color> (*(limb =
limbs++) == <color><param>0000,0000,FFFD</param>0</color> && sizeNew >
<color><param>0000,0000,FFFD</param>1</color>)

    {

        <color><param>2321,6E6C,2523</param>//free(limb);</color>

        sizeNew--;

    }

    

    f->_mp_size = sizeNew;

   
</fixed><bold><fontfamily><param>Times New Roman</param><bigger><bigger><bigger><bigger><bigger><bigger>f->_mp_d
= limb;</bigger></bigger></bigger></bigger></bigger></bigger></fontfamily></bold><fixed>

    

    <color><param>7674,0F0D,504E</param>return</color> f->_mp_size -
sizeNew;

}</fixed>
--Apple-Mail-2-797485669--