Allocated Limbs
delta trinity
deltatrinity@hotmail.com
Wed, 25 Jun 2003 09:11:27 -0400
Because, for example, if you have (or if GMP have) allocated a memory block
@ memory location 10000 (fictive example), and that you got allocated 5
limbs. If your number take the 5 limbs but with the two lower limbs == zero
(the case that you explained, where you want to flush the low limbs),
assuming one limb take 4 bytes (32 bits):
Memory - Value
10000 - 00000000 <-_mp_d point here (_mp_d = 10000)
10004 - 00000000
10008 - 12345678
1000C - A5A5A5A5
10010 - 87654321
Now, the algorithm detect the two low limbs. One thing you can do, is to
point _mp_d 2 limbs up:
10000 - 00000000
10004 - 00000000
10008 - 12345678 <-_mp_d point here (_mp_d = 10008)
1000C - A5A5A5A5
10010 - 87654321
(set _mp_size to 3)
But, the problem, if you were to do this, is that the memory block that got
allocated (internally by malloc or whatever), was at memory location 10000.
And the memory managements routines expect you to return back the value that
they gave. If you were to do operations on the mpf_t, that would make mpf_t
realloc or free the memory block, then, GMP would call those memory function
with the new _mp_d value (_mp_d is the only way GMP internally keep track of
allocated memory block).
So, the only way do to it safely, is to move the limbs down, like this
10000 - 12345678 <-_mp_d point here (_mp_d = 10008)
10004 - A5A5A5A5
10008 - 87654321
1000C - xxxxxxxx
10010 - xxxxxxxx
(set _mp_size to 3).
So, this way, this won't affect further memory management operations.
>From: LingWitt@insightbb.com
>To: Kevin Ryde <user42@zip.com.au>
>CC: gmp-discuss@swox.com
>Subject: Re: Allocated Limbs
>Date: Tue, 24 Jun 2003 21:09:49 -0400
>
>What is the purpose of moving array elements down in the same block?
>
>On Tuesday, Jun 24, 2003, at 20:04 America/New_York, Kevin Ryde wrote:
>
>>move the array elements (ie. limbs) within it.
>
>_______________________________________________
>gmp-discuss mailing list
>gmp-discuss@swox.com
>https://gmplib.org/mailman/listinfo/gmp-discuss
_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8.
http://join.msn.com/?page=features/junkmail