Ignore:
Timestamp:
1999-10-18T12:43:31+13:00 (25 years ago)
Author:
cs025
Message:

Changes to eradicate Xmalloc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/mgpp/text/mg_invf_rebuild.cpp

    r655 r711  
    5050/*
    5151   $Log$
     52   Revision 1.2  1999/10/17 23:43:26  cs025
     53   Changes to eradicate Xmalloc
     54
    5255   Revision 1.1  1999/10/11 02:57:58  cs025
    5356   Base install of MG-PP
     
    355358  for (i = 0; i < ifh_in.no_of_words; i++)
    356359    {
    357       unsigned long blk, p;
     360      unsigned long blk, docCount;
    358361      unsigned long odn_blk = 0, olen_blk = 0;
    359362      unsigned long idn_blk = 0, ilen_blk = 0;
     
    374377      NTOHUL(bytes_out);  /* [RPAP - Jan 97: Endian Ordering] */
    375378
    376       p = word.documents();
    377       blk = BIO_Bblock_Init (idh.static_num_of_docs, p);
     379      docCount = word.documents();
     380      blk = BIO_Bblock_Init (idh.static_num_of_docs, docCount);
    378381      switch (outmode)
    379382    {
     
    381384      {
    382385        unsigned long len;
    383         if (p <= ifh_out.params[0])
     386        if (docCount <= ifh_out.params[0])
    384387          out_k = 0;
    385388        else
    386389          {
    387390        out_k = ifh_out.params[0];
    388         len = BIO_Bblock_Bound (N, p);
     391        len = BIO_Bblock_Bound (N, docCount);
    389392        if (ifh_in.InvfLevel >= 2)
    390393          len += word.words();
    391         odn_blk = BIO_Bblock_Init (idh.num_of_docs, (p + out_k - 1) / out_k);
    392         olen_blk = BIO_Bblock_Init (len, (p + out_k - 1) / out_k);
     394        odn_blk = BIO_Bblock_Init (idh.num_of_docs, (docCount + out_k - 1) / out_k);
     395        olen_blk = BIO_Bblock_Init (len, (docCount + out_k - 1) / out_k);
    393396          }
    394397        break;
     
    397400      {
    398401        unsigned long len;
    399         if (p <= mins)
     402        if (docCount <= mins)
    400403          out_k = 0;
    401404        else
    402405          {
    403         out_k = (int) (2 * sqrt ((double) p / max_nodes));
     406        out_k = (int) (2 * sqrt ((double) docCount / max_nodes));
    404407        if (out_k <= mins)
    405408          out_k = mins;
    406         len = BIO_Bblock_Bound (N, p);
     409        len = BIO_Bblock_Bound (N, docCount);
    407410        if (ifh_in.InvfLevel >= 2)
    408411          len += word.words();
    409412        odn_blk = BIO_Bblock_Init (idh.num_of_docs,
    410                        (p + out_k - 1) / out_k);
    411         olen_blk = BIO_Bblock_Init (len, (p + out_k - 1) / out_k);
     413                       (docCount + out_k - 1) / out_k);
     414        olen_blk = BIO_Bblock_Init (len, (docCount + out_k - 1) / out_k);
    412415          }
    413416        break;
     
    422425      {
    423426        unsigned long len;
    424         if (p <= ifh_in.params[0])
     427        if (docCount <= ifh_in.params[0])
    425428          in_k = 0;
    426429        else
    427430          {
    428431        in_k = ifh_in.params[0];
    429         len = BIO_Bblock_Bound (N, p);
     432        len = BIO_Bblock_Bound (N, docCount);
    430433        if (ifh_in.InvfLevel >= 2)
    431434          len += word.words();
    432         idn_blk = BIO_Bblock_Init (idh.num_of_docs, (p + in_k - 1) / in_k);
    433         ilen_blk = BIO_Bblock_Init (len, (p + in_k - 1) / in_k);
     435        idn_blk = BIO_Bblock_Init (idh.num_of_docs, (docCount + in_k - 1) / in_k);
     436        ilen_blk = BIO_Bblock_Init (len, (docCount + in_k - 1) / in_k);
    434437          }
    435438        break;
     
    438441      {
    439442        unsigned long len;
    440         if (p <= ifh_in.params[1])
     443        if (docCount <= ifh_in.params[1])
    441444          {
    442445        in_k = 0;
     
    444447        else
    445448          {
    446         in_k = (int) (2 * sqrt ((double) p / ifh_in.params[0]));
     449        in_k = (int) (2 * sqrt ((double) docCount / ifh_in.params[0]));
    447450        if (in_k <= ifh_in.params[1])
    448451          in_k = ifh_in.params[1];
    449         len = BIO_Bblock_Bound (N, p);
     452        len = BIO_Bblock_Bound (N, docCount);
    450453        if (ifh_in.InvfLevel >= 2)
    451454          len += word.words();
    452455        idn_blk = BIO_Bblock_Init (idh.num_of_docs,
    453                        (p + in_k - 1) / in_k);
    454         ilen_blk = BIO_Bblock_Init (len, (p + in_k - 1) / in_k);
     456                       (docCount + in_k - 1) / in_k);
     457        ilen_blk = BIO_Bblock_Init (len, (docCount + in_k - 1) / in_k);
    455458          }
    456459        break;
     
    460463    }
    461464
    462       if (!(ii = (invf_info *) Xmalloc (sizeof (invf_info) * p)))
     465      if (!(ii = (invf_info *) Xmalloc (sizeof (invf_info) * docCount)))
    463466    FatalError (1, "Unable to allocate memory for \"ii\"\n");
    464467
     
    467470      kd = 0;
    468471      DECODE_CONTINUE (in_buf)
    469     for (j = 0; j < p; j++, kd++)
     472    for (j = 0; j < docCount; j++, kd++)
    470473    {
    471474      unsigned long doc_diff, count = 0;
    472475      if (kd == in_k)
    473476        kd = 0;
    474       if (in_k && kd == 0 && j + in_k < p)
     477      if (in_k && kd == 0 && j + in_k < docCount)
    475478        {
    476479          int temp;
     
    480483        }
    481484      ii[j].bits_so_far = bits_so_far;
    482       if (in_k && kd == in_k - 1 && j != p - 1)
     485      if (in_k && kd == in_k - 1 && j != docCount - 1)
    483486        {
    484487          int count;
     
    517520      kd = 0;
    518521      ENCODE_CONTINUE (out_buf)
    519     for (j = 0; j < p; j++, kd++)
     522    for (j = 0; j < docCount; j++, kd++)
    520523    {
    521524      if (kd == out_k)
     
    523526      if (out_k && kd == 0)
    524527        {
    525           if (j + out_k < p)
     528          if (j + out_k < docCount)
    526529        {
    527530          int num = ii[j + out_k - 1].doc_num - last_major;
     
    535538        }
    536539        }
    537       if (!(out_k && kd == out_k - 1 && j != p - 1))
     540      if (!(out_k && kd == out_k - 1 && j != docCount - 1))
    538541        buffer.bblock_encode (ii[j].doc_num - doc_num, blk, &bits_out);
    539542      doc_num = ii[j].doc_num;
Note: See TracChangeset for help on using the changeset viewer.