mirror of
https://github.com/lcn2/calc.git
synced 2025-08-19 01:13:27 +03:00
convert ASCII TABs to ASCII SPACEs
Converted all ASCII tabs to ASCII spaces using a 8 character tab stop, for all files, except for all Makefiles (plus rpm.mk). The `git diff -w` reports no changes.
This commit is contained in:
490
qmod.c
490
qmod.c
@@ -11,7 +11,7 @@
|
||||
*
|
||||
* Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
* Public License for more details.
|
||||
*
|
||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
@@ -19,10 +19,10 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* Under source code control: 1991/05/22 23:15:07
|
||||
* File existed as early as: 1991
|
||||
* Under source code control: 1991/05/22 23:15:07
|
||||
* File existed as early as: 1991
|
||||
*
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
@@ -32,21 +32,21 @@
|
||||
|
||||
|
||||
#include "errtbl.h"
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
/*
|
||||
* Structure used for caching REDC information.
|
||||
*/
|
||||
typedef struct {
|
||||
NUMBER *rnum; /* modulus being cached */
|
||||
REDC *redc; /* REDC information for modulus */
|
||||
long age; /* age counter for reallocation */
|
||||
typedef struct {
|
||||
NUMBER *rnum; /* modulus being cached */
|
||||
REDC *redc; /* REDC information for modulus */
|
||||
long age; /* age counter for reallocation */
|
||||
} REDC_CACHE;
|
||||
|
||||
|
||||
STATIC long redc_age; /* current age counter */
|
||||
STATIC REDC_CACHE redc_cache[MAXREDC]; /* cached REDC info */
|
||||
STATIC long redc_age; /* current age counter */
|
||||
STATIC REDC_CACHE redc_cache[MAXREDC]; /* cached REDC info */
|
||||
|
||||
|
||||
S_FUNC REDC *qfindredc(NUMBER *q);
|
||||
@@ -62,40 +62,40 @@ S_FUNC REDC *qfindredc(NUMBER *q);
|
||||
NUMBER *
|
||||
qmod(NUMBER *q1, NUMBER *q2, long rnd)
|
||||
{
|
||||
ZVALUE tmp, tmp1, tmp2;
|
||||
NUMBER *q;
|
||||
ZVALUE tmp, tmp1, tmp2;
|
||||
NUMBER *q;
|
||||
|
||||
if (qiszero(q2)) return qlink(q1);
|
||||
if (qiszero(q1)) return qlink(&_qzero_);
|
||||
if (qisint(q1) && qisint(q2)) { /* easy case */
|
||||
zmod(q1->num, q2->num, &tmp, rnd);
|
||||
if (ziszero(tmp)) {
|
||||
zfree(tmp);
|
||||
return qlink(&_qzero_);
|
||||
}
|
||||
if(zisone(tmp)) {
|
||||
zfree(tmp);
|
||||
return qlink(&_qone_);
|
||||
}
|
||||
q = qalloc();
|
||||
q->num = tmp;
|
||||
return q;
|
||||
}
|
||||
zmul(q1->num, q2->den, &tmp1);
|
||||
zmul(q2->num, q1->den, &tmp2);
|
||||
zmod(tmp1, tmp2, &tmp, rnd);
|
||||
zfree(tmp1);
|
||||
zfree(tmp2);
|
||||
if (ziszero(tmp)) {
|
||||
zfree(tmp);
|
||||
return qlink(&_qzero_);
|
||||
}
|
||||
zmul(q1->den, q2->den, &tmp1);
|
||||
q = qalloc();
|
||||
zreduce(tmp, tmp1, &q->num, &q->den);
|
||||
zfree(tmp1);
|
||||
zfree(tmp);
|
||||
return q;
|
||||
if (qiszero(q2)) return qlink(q1);
|
||||
if (qiszero(q1)) return qlink(&_qzero_);
|
||||
if (qisint(q1) && qisint(q2)) { /* easy case */
|
||||
zmod(q1->num, q2->num, &tmp, rnd);
|
||||
if (ziszero(tmp)) {
|
||||
zfree(tmp);
|
||||
return qlink(&_qzero_);
|
||||
}
|
||||
if(zisone(tmp)) {
|
||||
zfree(tmp);
|
||||
return qlink(&_qone_);
|
||||
}
|
||||
q = qalloc();
|
||||
q->num = tmp;
|
||||
return q;
|
||||
}
|
||||
zmul(q1->num, q2->den, &tmp1);
|
||||
zmul(q2->num, q1->den, &tmp2);
|
||||
zmod(tmp1, tmp2, &tmp, rnd);
|
||||
zfree(tmp1);
|
||||
zfree(tmp2);
|
||||
if (ziszero(tmp)) {
|
||||
zfree(tmp);
|
||||
return qlink(&_qzero_);
|
||||
}
|
||||
zmul(q1->den, q2->den, &tmp1);
|
||||
q = qalloc();
|
||||
zreduce(tmp, tmp1, &q->num, &q->den);
|
||||
zfree(tmp1);
|
||||
zfree(tmp);
|
||||
return q;
|
||||
}
|
||||
|
||||
|
||||
@@ -114,68 +114,68 @@ qmod(NUMBER *q1, NUMBER *q2, long rnd)
|
||||
* nonzero or zero
|
||||
*
|
||||
* Given:
|
||||
* q1 number to be divided
|
||||
* q2 divisor
|
||||
* quo quotient
|
||||
* mod remainder
|
||||
* rnd rounding-type specifier
|
||||
* q1 number to be divided
|
||||
* q2 divisor
|
||||
* quo quotient
|
||||
* mod remainder
|
||||
* rnd rounding-type specifier
|
||||
*/
|
||||
bool
|
||||
qquomod(NUMBER *q1, NUMBER *q2, NUMBER **quo, NUMBER **mod, long rnd)
|
||||
{
|
||||
NUMBER *qq, *qm;
|
||||
ZVALUE tmp1, tmp2, tmp3, tmp4;
|
||||
NUMBER *qq, *qm;
|
||||
ZVALUE tmp1, tmp2, tmp3, tmp4;
|
||||
|
||||
if (qiszero(q2)) { /* zero divisor case */
|
||||
qq = qlink(&_qzero_);
|
||||
qm = qlink(q1);
|
||||
} else if (qisint(q1) && qisint(q2)) { /* integer args case */
|
||||
zdiv(q1->num, q2->num, &tmp1, &tmp2, rnd);
|
||||
if (ziszero(tmp1)) {
|
||||
zfree(tmp1);
|
||||
zfree(tmp2);
|
||||
qq = qlink(&_qzero_);
|
||||
qm = qlink(q1);
|
||||
} else {
|
||||
qq = qalloc();
|
||||
qq->num = tmp1;
|
||||
if (ziszero(tmp2)) {
|
||||
zfree(tmp2);
|
||||
qm = qlink(&_qzero_);
|
||||
} else {
|
||||
qm = qalloc();
|
||||
qm->num = tmp2;
|
||||
}
|
||||
}
|
||||
} else { /* fractional case */
|
||||
zmul(q1->num, q2->den, &tmp1);
|
||||
zmul(q2->num, q1->den, &tmp2);
|
||||
zdiv(tmp1, tmp2, &tmp3, &tmp4, rnd);
|
||||
zfree(tmp1);
|
||||
zfree(tmp2);
|
||||
if (ziszero(tmp3)) {
|
||||
zfree(tmp3);
|
||||
zfree(tmp4);
|
||||
qq = qlink(&_qzero_);
|
||||
qm = qlink(q1);
|
||||
} else {
|
||||
qq = qalloc();
|
||||
qq->num = tmp3;
|
||||
if (ziszero(tmp4)) {
|
||||
zfree(tmp4);
|
||||
qm = qlink(&_qzero_);
|
||||
} else {
|
||||
qm = qalloc();
|
||||
zmul(q1->den, q2->den, &tmp1);
|
||||
zreduce(tmp4, tmp1, &qm->num, &qm->den);
|
||||
zfree(tmp1);
|
||||
zfree(tmp4);
|
||||
}
|
||||
}
|
||||
}
|
||||
*quo = qq;
|
||||
*mod = qm;
|
||||
return !qiszero(qm);
|
||||
if (qiszero(q2)) { /* zero divisor case */
|
||||
qq = qlink(&_qzero_);
|
||||
qm = qlink(q1);
|
||||
} else if (qisint(q1) && qisint(q2)) { /* integer args case */
|
||||
zdiv(q1->num, q2->num, &tmp1, &tmp2, rnd);
|
||||
if (ziszero(tmp1)) {
|
||||
zfree(tmp1);
|
||||
zfree(tmp2);
|
||||
qq = qlink(&_qzero_);
|
||||
qm = qlink(q1);
|
||||
} else {
|
||||
qq = qalloc();
|
||||
qq->num = tmp1;
|
||||
if (ziszero(tmp2)) {
|
||||
zfree(tmp2);
|
||||
qm = qlink(&_qzero_);
|
||||
} else {
|
||||
qm = qalloc();
|
||||
qm->num = tmp2;
|
||||
}
|
||||
}
|
||||
} else { /* fractional case */
|
||||
zmul(q1->num, q2->den, &tmp1);
|
||||
zmul(q2->num, q1->den, &tmp2);
|
||||
zdiv(tmp1, tmp2, &tmp3, &tmp4, rnd);
|
||||
zfree(tmp1);
|
||||
zfree(tmp2);
|
||||
if (ziszero(tmp3)) {
|
||||
zfree(tmp3);
|
||||
zfree(tmp4);
|
||||
qq = qlink(&_qzero_);
|
||||
qm = qlink(q1);
|
||||
} else {
|
||||
qq = qalloc();
|
||||
qq->num = tmp3;
|
||||
if (ziszero(tmp4)) {
|
||||
zfree(tmp4);
|
||||
qm = qlink(&_qzero_);
|
||||
} else {
|
||||
qm = qalloc();
|
||||
zmul(q1->den, q2->den, &tmp1);
|
||||
zreduce(tmp4, tmp1, &qm->num, &qm->den);
|
||||
zfree(tmp1);
|
||||
zfree(tmp4);
|
||||
}
|
||||
}
|
||||
}
|
||||
*quo = qq;
|
||||
*mod = qm;
|
||||
return !qiszero(qm);
|
||||
}
|
||||
|
||||
|
||||
@@ -186,13 +186,13 @@ qquomod(NUMBER *q1, NUMBER *q2, NUMBER **quo, NUMBER **mod, long rnd)
|
||||
bool
|
||||
qcmpmod(NUMBER *q1, NUMBER *q2, NUMBER *q3)
|
||||
{
|
||||
if (qisneg(q3) || qiszero(q3))
|
||||
math_error("Non-positive modulus");
|
||||
if (qisfrac(q1) || qisfrac(q2) || qisfrac(q3))
|
||||
math_error("Non-integers for qcmpmod");
|
||||
if (q1 == q2)
|
||||
return false;
|
||||
return zcmpmod(q1->num, q2->num, q3->num);
|
||||
if (qisneg(q3) || qiszero(q3))
|
||||
math_error("Non-positive modulus");
|
||||
if (qisfrac(q1) || qisfrac(q2) || qisfrac(q3))
|
||||
math_error("Non-integers for qcmpmod");
|
||||
if (q1 == q2)
|
||||
return false;
|
||||
return zcmpmod(q1->num, q2->num, q3->num);
|
||||
}
|
||||
|
||||
|
||||
@@ -201,25 +201,25 @@ qcmpmod(NUMBER *q1, NUMBER *q2, NUMBER *q3)
|
||||
* The number can be negative or out of modulus range.
|
||||
*
|
||||
* given:
|
||||
* q1 number to convert into REDC format
|
||||
* q2 modulus
|
||||
* q1 number to convert into REDC format
|
||||
* q2 modulus
|
||||
*/
|
||||
NUMBER *
|
||||
qredcin(NUMBER *q1, NUMBER *q2)
|
||||
{
|
||||
REDC *rp; /* REDC information */
|
||||
NUMBER *r; /* result */
|
||||
REDC *rp; /* REDC information */
|
||||
NUMBER *r; /* result */
|
||||
|
||||
if (qisfrac(q1))
|
||||
math_error("Non-integer for qredcin");
|
||||
rp = qfindredc(q2);
|
||||
r = qalloc();
|
||||
zredcencode(rp, q1->num, &r->num);
|
||||
if (qiszero(r)) {
|
||||
qfree(r);
|
||||
return qlink(&_qzero_);
|
||||
}
|
||||
return r;
|
||||
if (qisfrac(q1))
|
||||
math_error("Non-integer for qredcin");
|
||||
rp = qfindredc(q2);
|
||||
r = qalloc();
|
||||
zredcencode(rp, q1->num, &r->num);
|
||||
if (qiszero(r)) {
|
||||
qfree(r);
|
||||
return qlink(&_qzero_);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
@@ -228,27 +228,27 @@ qredcin(NUMBER *q1, NUMBER *q2)
|
||||
* The resulting number is in the range 0 to the modulus - 1.
|
||||
*
|
||||
* given:
|
||||
* q1 number to convert into REDC format
|
||||
* q2 modulus
|
||||
* q1 number to convert into REDC format
|
||||
* q2 modulus
|
||||
*/
|
||||
NUMBER *
|
||||
qredcout(NUMBER *q1, NUMBER *q2)
|
||||
{
|
||||
REDC *rp; /* REDC information */
|
||||
NUMBER *r; /* result */
|
||||
REDC *rp; /* REDC information */
|
||||
NUMBER *r; /* result */
|
||||
|
||||
if (qisfrac(q1))
|
||||
math_error("Non-integer argument for rcout");
|
||||
rp = qfindredc(q2);
|
||||
if (qiszero(q1) || qisunit(q2))
|
||||
return qlink(&_qzero_);
|
||||
r = qalloc();
|
||||
zredcdecode(rp, q1->num, &r->num);
|
||||
if (zisunit(r->num)) {
|
||||
qfree(r);
|
||||
r = qlink(&_qone_);
|
||||
}
|
||||
return r;
|
||||
if (qisfrac(q1))
|
||||
math_error("Non-integer argument for rcout");
|
||||
rp = qfindredc(q2);
|
||||
if (qiszero(q1) || qisunit(q2))
|
||||
return qlink(&_qzero_);
|
||||
r = qalloc();
|
||||
zredcdecode(rp, q1->num, &r->num);
|
||||
if (zisunit(r->num)) {
|
||||
qfree(r);
|
||||
r = qlink(&_qone_);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
@@ -257,24 +257,24 @@ qredcout(NUMBER *q1, NUMBER *q2)
|
||||
* This multiplication is done modulo the specified modulus.
|
||||
*
|
||||
* given:
|
||||
* q1 REDC numbers to be multiplied
|
||||
* q2 REDC numbers to be multiplied
|
||||
* q3 modulus
|
||||
* q1 REDC numbers to be multiplied
|
||||
* q2 REDC numbers to be multiplied
|
||||
* q3 modulus
|
||||
*/
|
||||
NUMBER *
|
||||
qredcmul(NUMBER *q1, NUMBER *q2, NUMBER *q3)
|
||||
{
|
||||
REDC *rp; /* REDC information */
|
||||
NUMBER *r; /* result */
|
||||
REDC *rp; /* REDC information */
|
||||
NUMBER *r; /* result */
|
||||
|
||||
if (qisfrac(q1) || qisfrac(q2))
|
||||
math_error("Non-integer argument for rcmul");
|
||||
rp = qfindredc(q3);
|
||||
if (qiszero(q1) || qiszero(q2) || qisunit(q3))
|
||||
return qlink(&_qzero_);
|
||||
r = qalloc();
|
||||
zredcmul(rp, q1->num, q2->num, &r->num);
|
||||
return r;
|
||||
if (qisfrac(q1) || qisfrac(q2))
|
||||
math_error("Non-integer argument for rcmul");
|
||||
rp = qfindredc(q3);
|
||||
if (qiszero(q1) || qiszero(q2) || qisunit(q3))
|
||||
return qlink(&_qzero_);
|
||||
r = qalloc();
|
||||
zredcmul(rp, q1->num, q2->num, &r->num);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
@@ -283,23 +283,23 @@ qredcmul(NUMBER *q1, NUMBER *q2, NUMBER *q3)
|
||||
* This squaring is done modulo the specified modulus.
|
||||
*
|
||||
* given:
|
||||
* q1 REDC numbers to be squared
|
||||
* q2 modulus
|
||||
* q1 REDC numbers to be squared
|
||||
* q2 modulus
|
||||
*/
|
||||
NUMBER *
|
||||
qredcsquare(NUMBER *q1, NUMBER *q2)
|
||||
{
|
||||
REDC *rp; /* REDC information */
|
||||
NUMBER *r; /* result */
|
||||
REDC *rp; /* REDC information */
|
||||
NUMBER *r; /* result */
|
||||
|
||||
if (qisfrac(q1))
|
||||
math_error("Non-integer argument for rcsq");
|
||||
rp = qfindredc(q2);
|
||||
if (qiszero(q1) || qisunit(q2))
|
||||
return qlink(&_qzero_);
|
||||
r = qalloc();
|
||||
zredcsquare(rp, q1->num, &r->num);
|
||||
return r;
|
||||
if (qisfrac(q1))
|
||||
math_error("Non-integer argument for rcsq");
|
||||
rp = qfindredc(q2);
|
||||
if (qiszero(q1) || qisunit(q2))
|
||||
return qlink(&_qzero_);
|
||||
r = qalloc();
|
||||
zredcsquare(rp, q1->num, &r->num);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
@@ -309,122 +309,122 @@ qredcsquare(NUMBER *q1, NUMBER *q2)
|
||||
* power to be raised to is a normal number.
|
||||
*
|
||||
* given:
|
||||
* q1 REDC number to be raised
|
||||
* q2 power to be raised to
|
||||
* q3 modulus
|
||||
* q1 REDC number to be raised
|
||||
* q2 power to be raised to
|
||||
* q3 modulus
|
||||
*/
|
||||
NUMBER *
|
||||
qredcpower(NUMBER *q1, NUMBER *q2, NUMBER *q3)
|
||||
{
|
||||
REDC *rp; /* REDC information */
|
||||
NUMBER *r; /* result */
|
||||
REDC *rp; /* REDC information */
|
||||
NUMBER *r; /* result */
|
||||
|
||||
if (qisfrac(q1) || qisfrac(q2) || qisfrac(q2))
|
||||
math_error("Non-integer argument for rcpow");
|
||||
if (qisneg(q2))
|
||||
math_error("Negative exponent argument for rcpow");
|
||||
rp = qfindredc(q3);
|
||||
r = qalloc();
|
||||
zredcpower(rp, q1->num, q2->num, &r->num);
|
||||
return r;
|
||||
if (qisfrac(q1) || qisfrac(q2) || qisfrac(q2))
|
||||
math_error("Non-integer argument for rcpow");
|
||||
if (qisneg(q2))
|
||||
math_error("Negative exponent argument for rcpow");
|
||||
rp = qfindredc(q3);
|
||||
r = qalloc();
|
||||
zredcpower(rp, q1->num, q2->num, &r->num);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Search for and return the REDC information for the specified number.
|
||||
* The information is cached into a local table so that future calls
|
||||
* for this information will be quick. If the table fills up, then
|
||||
* for this information will be quick. If the table fills up, then
|
||||
* the oldest cached entry is reused.
|
||||
*
|
||||
* given:
|
||||
* q modulus to find REDC information of
|
||||
* q modulus to find REDC information of
|
||||
*/
|
||||
S_FUNC REDC *
|
||||
qfindredc(NUMBER *q)
|
||||
{
|
||||
register REDC_CACHE *rcp;
|
||||
REDC_CACHE *bestrcp;
|
||||
register REDC_CACHE *rcp;
|
||||
REDC_CACHE *bestrcp;
|
||||
|
||||
/*
|
||||
* First try for an exact pointer match in the table.
|
||||
*/
|
||||
for (rcp = redc_cache; rcp <= &redc_cache[MAXREDC-1]; rcp++) {
|
||||
if (q == rcp->rnum) {
|
||||
rcp->age = ++redc_age;
|
||||
return rcp->redc;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* First try for an exact pointer match in the table.
|
||||
*/
|
||||
for (rcp = redc_cache; rcp <= &redc_cache[MAXREDC-1]; rcp++) {
|
||||
if (q == rcp->rnum) {
|
||||
rcp->age = ++redc_age;
|
||||
return rcp->redc;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Search the table again looking for a value which matches.
|
||||
*/
|
||||
for (rcp = redc_cache; rcp <= &redc_cache[MAXREDC-1]; rcp++) {
|
||||
if (rcp->age && (qcmp(q, rcp->rnum) == 0)) {
|
||||
rcp->age = ++redc_age;
|
||||
return rcp->redc;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Search the table again looking for a value which matches.
|
||||
*/
|
||||
for (rcp = redc_cache; rcp <= &redc_cache[MAXREDC-1]; rcp++) {
|
||||
if (rcp->age && (qcmp(q, rcp->rnum) == 0)) {
|
||||
rcp->age = ++redc_age;
|
||||
return rcp->redc;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Must invalidate an existing entry in the table.
|
||||
* Find the oldest (or first unused) entry.
|
||||
* But first make sure the modulus will be reasonable.
|
||||
*/
|
||||
if (qisfrac(q) || qisneg(q)) {
|
||||
math_error("REDC modulus must be positive odd integer");
|
||||
not_reached();
|
||||
}
|
||||
/*
|
||||
* Must invalidate an existing entry in the table.
|
||||
* Find the oldest (or first unused) entry.
|
||||
* But first make sure the modulus will be reasonable.
|
||||
*/
|
||||
if (qisfrac(q) || qisneg(q)) {
|
||||
math_error("REDC modulus must be positive odd integer");
|
||||
not_reached();
|
||||
}
|
||||
|
||||
bestrcp = NULL;
|
||||
for (rcp = redc_cache; rcp <= &redc_cache[MAXREDC-1]; rcp++) {
|
||||
if ((bestrcp == NULL) || (rcp->age < bestrcp->age))
|
||||
bestrcp = rcp;
|
||||
}
|
||||
bestrcp = NULL;
|
||||
for (rcp = redc_cache; rcp <= &redc_cache[MAXREDC-1]; rcp++) {
|
||||
if ((bestrcp == NULL) || (rcp->age < bestrcp->age))
|
||||
bestrcp = rcp;
|
||||
}
|
||||
|
||||
/*
|
||||
* Found the best entry.
|
||||
* Free the old information for the entry if necessary,
|
||||
* then initialize it.
|
||||
*/
|
||||
rcp = bestrcp;
|
||||
if (rcp->age) {
|
||||
rcp->age = 0;
|
||||
qfree(rcp->rnum);
|
||||
zredcfree(rcp->redc);
|
||||
}
|
||||
/*
|
||||
* Found the best entry.
|
||||
* Free the old information for the entry if necessary,
|
||||
* then initialize it.
|
||||
*/
|
||||
rcp = bestrcp;
|
||||
if (rcp->age) {
|
||||
rcp->age = 0;
|
||||
qfree(rcp->rnum);
|
||||
zredcfree(rcp->redc);
|
||||
}
|
||||
|
||||
rcp->redc = zredcalloc(q->num);
|
||||
rcp->rnum = qlink(q);
|
||||
rcp->age = ++redc_age;
|
||||
return rcp->redc;
|
||||
rcp->redc = zredcalloc(q->num);
|
||||
rcp->rnum = qlink(q);
|
||||
rcp->age = ++redc_age;
|
||||
return rcp->redc;
|
||||
}
|
||||
|
||||
void
|
||||
showredcdata(void)
|
||||
{
|
||||
REDC_CACHE *rcp;
|
||||
long i;
|
||||
REDC_CACHE *rcp;
|
||||
long i;
|
||||
|
||||
for (i = 0, rcp = redc_cache; i < MAXREDC; i++, rcp++) {
|
||||
if (rcp->age > 0) {
|
||||
printf("%-8ld%-8ld", i, rcp->age);
|
||||
qprintnum(rcp->rnum, 0, conf->outdigits);
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
for (i = 0, rcp = redc_cache; i < MAXREDC; i++, rcp++) {
|
||||
if (rcp->age > 0) {
|
||||
printf("%-8ld%-8ld", i, rcp->age);
|
||||
qprintnum(rcp->rnum, 0, conf->outdigits);
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
freeredcdata(void)
|
||||
{
|
||||
REDC_CACHE *rcp;
|
||||
long i;
|
||||
REDC_CACHE *rcp;
|
||||
long i;
|
||||
|
||||
for (i = 0, rcp = redc_cache; i < MAXREDC; i++, rcp++) {
|
||||
if (rcp->age > 0) {
|
||||
rcp->age = 0;
|
||||
qfree(rcp->rnum);
|
||||
zredcfree(rcp->redc);
|
||||
}
|
||||
}
|
||||
for (i = 0, rcp = redc_cache; i < MAXREDC; i++, rcp++) {
|
||||
if (rcp->age > 0) {
|
||||
rcp->age = 0;
|
||||
qfree(rcp->rnum);
|
||||
zredcfree(rcp->redc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user