Changeset 711 for trunk/gsdl/src


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

Changes to eradicate Xmalloc

Location:
trunk/gsdl/src/mgpp/text
Files:
18 edited

Legend:

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

    r655 r711  
    4040  if (de->CompTextBuffer)
    4141  {
    42     Xfree (de->CompTextBuffer);
     42    delete de->CompTextBuffer;
    4343    de->CompTextBuffer = NULL;
    4444    return de->Len;
  • trunk/gsdl/src/mgpp/text/StemBlock.cpp

    r655 r711  
    4545  int abortvar;
    4646
    47   if (!(sd = (stemmed_dict *) Xmalloc (sizeof (stemmed_dict))))
     47  if (!(sd = new stemmed_dict))
    4848    {
    4949      abort(0);
     
    6666  NTOHUL(sd->sdh.indexed);
    6767
    68   if (!(buffer = (u_char *) Xmalloc (sd->sdh.index_chars)))
     68  if (!(buffer = new u_char[sd->sdh.index_chars]))
    6969    {
    7070      abort(1);
     
    7272  sd->MemForStemDict += sd->sdh.index_chars;
    7373
    74   if (!(sd->index = (u_char **) Xmalloc (sd->sdh.num_blocks * sizeof (*sd->index))))
     74  if (!(sd->index = new (u_char *)[sd->sdh.num_blocks]))
    7575    {
    7676      abort(2);
     
    7878  sd->MemForStemDict += sd->sdh.num_blocks * sizeof (*sd->index);
    7979
    80   if (!(sd->pos = (long unsigned int *) Xmalloc (sd->sdh.num_blocks * sizeof (*sd->pos))))
     80  if (!(sd->pos = new (long unsigned int)[sd->sdh.num_blocks]))
    8181    {
    8282      abort(3);
     
    8484  sd->MemForStemDict += sd->sdh.num_blocks * sizeof (*sd->pos);
    8585
    86   if (!(sd->buffer = (u_char *) Xmalloc (sd->sdh.block_size * sizeof (*sd->buffer))))
     86  if (!(sd->buffer = new u_char[sd->sdh.block_size]))
    8787    {
    8888      abort(4);
     
    9595    {
    9696      register u_char len;
     97      // Read an MG string from the blocked dictionary
    9798      sd->index[i] = buffer;
    9899      len = Getc (stem_file);
     
    100101      Fread (buffer, sizeof (u_char), len, stem_file);
    101102      buffer += len;
     103
     104      // Read the pointer into the blocks
    102105      Fread (&sd->pos[i], sizeof (*sd->pos), 1, stem_file);
     106
    103107      NTOHUL(sd->pos[i]); /* [RPAP - Jan 97: Endian Ordering] */
    104108    }
     
    114118    {
    115119      case 4:
    116         Xfree (sd->buffer);
     120        delete sd->pos;
    117121      case 3:
    118         Xfree (sd->index);
     122        delete sd->index;
    119123      case 2:
    120         Xfree (buffer);
     124        delete buffer;
    121125      case 1:
    122         Xfree (sd);
     126        delete sd;
    123127      break;
    124128
     
    158162
    159163      /* [RPAP - Jan 97: Endian Ordering] */
     164      // first_word is the word number of the first word in the block
    160165      *first_word = (unsigned long *) (sd->buffer);
    161166      NTOHUL(**first_word);
     167
    162168      *last_invf_len = (unsigned long *) ((*first_word) + 1);
    163169      NTOHUL(**last_invf_len);
     170
     171      // num_words is the number of words in the block
    164172      *num_words = (unsigned short *) ((*last_invf_len) + 1);
    165173      NTOHUS(**num_words);
     174
    166175      *index = (*num_words) + 1;
    167176      *num_indexes = (((**num_words) - 1) / sd->sdh.lookback) + 1;
  • trunk/gsdl/src/mgpp/text/StemIdx.cpp

    r655 r711  
    2222  int abortvar;
    2323
    24   if (!(si = (stemmed_idx *) Xmalloc (sizeof (stemmed_idx))))
     24  if (!(si = new stemmed_idx))
    2525    {
    2626      abort(0);
     
    4343  NTOHUL(si->sih.num_of_words);
    4444
    45   if (!(buffer = (u_char *) Xmalloc (si->sih.index_chars)))
     45  if (!(buffer = new u_char[si->sih.index_chars]))
    4646    {
    4747      abort(1);
     
    4949  si->MemForStemIdx += si->sih.index_chars;
    5050
    51   if (!(si->index = (u_char **) Xmalloc (si->sih.num_blocks * sizeof (*si->index))))
     51  if (!(si->index = new (u_char *)[si->sih.num_blocks]))
    5252    {
    5353      abort(2);
     
    5555  si->MemForStemIdx += si->sih.num_blocks * sizeof (*si->index);
    5656
    57   if (!(si->pos = (long unsigned int *) Xmalloc (si->sih.num_blocks * sizeof (*si->pos))))
     57  if (!(si->pos = new (unsigned long)[si->sih.num_blocks]))
    5858    {
    5959      abort(3);
     
    6161  si->MemForStemIdx += si->sih.num_blocks * sizeof (*si->pos);
    6262
    63   if (!(si->buffer = (u_char *) Xmalloc (si->sih.block_size * sizeof (*si->buffer))))
     63  if (!(si->buffer = new u_char[si->sih.block_size]))
    6464    {
    6565      abort(4);
     
    8686    {
    8787      case 4:
    88     Xfree(si->pos);
     88    delete si->pos;
    8989      case 3:
    90     Xfree(si->index);
     90    delete si->index;
    9191      case 2:
    92     Xfree(buffer);
     92    delete buffer;
    9393      case 1:
    94         Xfree(si);
     94        delete si;
    9595      break;
    9696    }
  • trunk/gsdl/src/mgpp/text/backend.cpp

    r655 r711  
    283283  if (textname == NULL) textname = name; /* [RJM 06/97: text filename] */
    284284
    285   if (!(qd = (query_data *) Xmalloc (sizeof (query_data))))
     285  if (!(qd = new query_data))
    286286    {
    287287      abort(0);
     
    326326    {
    327327      /* [RJM 06/97: text filename] */
    328       if (!(qd->pathname = (char *) Xmalloc (strlen (dir) + strlen (name) + 1)) ||
    329       !(qd->textpathname = (char *) Xmalloc (strlen (dir) + strlen (textname) + 1)))
     328      if (!(qd->pathname = new char[strlen (dir) + strlen (name) + 1]) ||
     329      !(qd->textpathname = new char[strlen (dir) + strlen (textname) + 1]))
    330330    {
    331331      abort(1);
     
    338338    {
    339339      /* [RJM 06/97: text filename] */
    340       if (!(qd->pathname = (char *) Xmalloc (strlen (dir) + strlen (name) + 2)) ||
    341       !(qd->textpathname = (char *) Xmalloc (strlen (dir) + strlen (textname) + 2)))
     340      if (!(qd->pathname = new char[strlen (dir) + strlen (name) + 2]) ||
     341      !(qd->textpathname = new char[strlen (dir) + strlen (textname) + 2]))
    342342    {
    343343      abort(1);
     
    509509
    510510      fread((void *)&magic, sizeof(magic), 1, paragraph);
    511       qd->paragraph = Xmalloc((qd->td->cth.num_of_docs+1)*sizeof(int));
     511      qd->paragraph = new int[qd->td->cth.num_of_docs+1];
    512512      qd->paragraph[0] = 0;
    513513      for (i = 1; i <= qd->td->cth.num_of_docs; i++)
     
    545545    size = ftell (f);
    546546    fseek (f, 0, 0);
    547     trec_ids = Xmalloc (size);
     547    trec_ids = new char[size];
    548548    if (!trec_ids)
    549549      {
     
    557557    int i, d;
    558558    unsigned long magic;
    559     trec_paras = Xmalloc (qd->sd->sdh.num_of_docs * sizeof (long));
     559    trec_paras = new long[qd->sd->sdh.num_of_docs];
    560560    if (!trec_paras)
    561561      {
    562         Xfree (trec_ids);
     562        delete trec_ids;
    563563        trec_ids = NULL;
    564564        goto error;
     
    595595  error:
    596596    if (trec_ids)
    597       Xfree (trec_ids);
     597      delete trec_ids;
    598598    if (trec_paras)
    599       Xfree (trec_paras);
     599      delete (trec_paras);
    600600    trec_ids = NULL;
    601601    trec_paras = NULL;
     
    629629      close_all_files (qd);
    630630    case 2:
    631       Xfree (qd->textpathname); /* [RJM 06/97: text filename] */
     631      delete (qd->textpathname); /* [RJM 06/97: text filename] */
    632632    case 1:
    633633      if (qd->pathname)
    634     Xfree (qd->pathname); /* [RJM 06/97: text filename] */
    635       Xfree (qd);
     634    delete (qd->pathname); /* [RJM 06/97: text filename] */
     635      delete qd;
    636636      break;
    637637    }
     
    679679#if defined(PARADOCNUM) || defined(NZDL)
    680680  if (qd->paragraph != NULL) {
    681     Xfree (qd->paragraph);
     681    delete (qd->paragraph);
    682682    qd->paragraph = NULL;
    683683  }
     
    696696  FreeStemDict (qd->sd);
    697697  close_all_files (qd);
    698   Xfree (qd->textpathname); /* [RJM 06/97: text filename] */
    699   Xfree (qd->pathname);
     698  delete (qd->textpathname); /* [RJM 06/97: text filename] */
     699  delete (qd->pathname);
    700700  QueryData_FreeQueryDocs (qd);
    701701  if (qd->TL != NULL) TermList_destroy(&qd->TL);         /* [RJM 07/98: Memory Leak] */
    702702  if (qd->QTL != NULL) QueryTermList_free(&qd->QTL);  /* [RJM 07/98: Memory Leak] */
    703   Xfree (qd);
     703  delete qd;
    704704
    705705  /* other global stuff hanging around */
     
    777777  if (qd->TextBuffer)
    778778    {
    779       Xfree (qd->TextBuffer);
     779      delete qd->TextBuffer;
    780780      ChangeMemInUse (qd, -qd->TextBufferLen);
    781781    }
     
    799799    if (qd->DL->DE[i].CompTextBuffer)
    800800      {
    801         Xfree (qd->DL->DE[i].CompTextBuffer);
     801        delete qd->DL->DE[i].CompTextBuffer;
    802802        qd->DL->DE[i].CompTextBuffer = NULL;
    803803        ChangeMemInUse (qd, -qd->DL->DE[i].Len);
     
    903903  qd->TextBufferLen = (int) (qd->td->cth.ratio * 1.01 *
    904904                 DocEntry_length(DE)) + 100;
    905   if (!(qd->TextBuffer = (unsigned char *) Xmalloc (qd->TextBufferLen)))
     905  if (!(qd->TextBuffer = new unsigned char[qd->TextBufferLen]))
    906906    {
    907907      fprintf (stderr, "No memory for TextBuffer\n");
  • trunk/gsdl/src/mgpp/text/bool_optimiser.cpp

    r655 r711  
    2424/*
    2525   $Log$
     26   Revision 1.2  1999/10/17 23:43:22  cs025
     27   Changes to eradicate Xmalloc
     28
    2629   Revision 1.1  1999/10/11 02:57:01  cs025
    2730   Base install of MG-PP
     
    159162  BOOL_SIBLING (not_tree) = sibling;
    160163
    161   Xfree (child);
    162   Xfree (a);
     164  delete (child);
     165  delete (a);
    163166
    164167}
     
    436439
    437440  bcopy ((void *) child, (void *) tree, sizeof (bool_tree_node));
    438   Xfree (child);
     441  delete (child);
    439442  BOOL_SIBLING (last) = next;
    440443
     
    475478          BOOL_TAG (tree) = N_none;
    476479          BOOL_CHILD (tree) = NULL;
    477           Xfree (child);
     480          delete (child);
    478481          break;
    479482        }
     
    484487          BOOL_TAG (tree) = N_all;
    485488          BOOL_CHILD (tree) = NULL;
    486           Xfree (child);
     489          delete (child);
    487490          break;
    488491        }
     
    544547        }
    545548
    546       Xfree (child);
     549      delete (child);
    547550      child = sibling;
    548551    }
     
    571574      bcopy ((void *) child, (void *) and_tree, sizeof (bool_tree_node));
    572575      BOOL_SIBLING (and_tree) = save_sibling;
    573       Xfree (child);
     576      delete (child);
    574577    }
    575578
     
    613616          BOOL_SIBLING (prev) = sibling;
    614617        }
    615       Xfree (child);
     618      delete (child);
    616619      child = sibling;
    617620
     
    641644      bcopy ((void *) child, (void *) or_tree, sizeof (bool_tree_node));
    642645      BOOL_SIBLING (or_tree) = save_sibling;
    643       Xfree (child);
     646      delete (child);
    644647    }
    645648
     
    726729    bool_tree_node *c = BOOL_CHILD (n);
    727730    next = BOOL_SIBLING (n);
    728     Xfree (n);
     731    delete (n);
    729732    if (next)
    730733      BOOL_SIBLING (c) = BOOL_CHILD (next);
     
    885888    }
    886889
    887   if (!(list = (bool_tree_node **) Xmalloc (sizeof (bool_tree_node *) * count)))
     890  if (!(list = new (bool_tree_node *)[count]))
    888891    return;
    889892
     
    904907  BOOL_SIBLING (list[count - 1]) = NULL;
    905908  BOOL_CHILD (and_tree) = list[0];
    906   Xfree (list);
     909  delete list;
    907910  /* ----------------------------------------------------- */
    908911
  • trunk/gsdl/src/mgpp/text/bool_parser.cpp

    r655 r711  
    231231    {
    232232      static char word[MAXSTEMLEN + 1]; /* [RJM 07/98: Memory Leak] */
    233       char *sWord = (char *) Xmalloc(MAXSTEMLEN + 1);
     233      char *sWord = new char[MAXSTEMLEN + 1];
    234234      int stem_to_apply, method_using = -1;
    235235
     
    270270          yylval.text = word;
    271271          *ptr = buf_ptr; /* fix up ptr */
    272           Xfree (sWord);
     272          delete sWord;
    273273          return TERM;
    274274        }
     
    282282          /* [RPAP - Feb 97: Term Frequency] */
    283283          int i, freq = 0;
    284           for (i = 0; i < Terms->size(); i++)
     284          for (i = 0; i < Terms->num; i++)
    285285            freq += Terms->TE[i].WE.count;
    286286          QueryTermList_AddQueryTerm (query_term_list, (unsigned char *) word, freq, method_using);
    287287
    288           Xfree (sWord);
     288          delete sWord;
    289289          mode = 1;
    290290          return '(';
     
    293293        {
    294294          /* Word does not exists - include in tree anyway */
    295           Xfree (sWord);
     295          delete sWord;
    296296
    297297          /* [RPAP - Feb 97: Term Frequency] */
     
    339339  else  /* mode == 2 */
    340340    {
    341       if (termnum >= Terms->size())
     341      if (termnum >= Terms->num)
    342342    {
    343343      mode = 0;
  • trunk/gsdl/src/mgpp/text/bool_tester.cpp

    r655 r711  
    2424/*
    2525   $Log$
     26   Revision 1.2  1999/10/17 23:43:23  cs025
     27   Changes to eradicate Xmalloc
     28
    2629   Revision 1.1  1999/10/11 02:57:06  cs025
    2730   Base install of MG-PP
     
    7679#define STEM_METHOD 3
    7780
    78 static FILE *file_in = stdin;
    79 static FILE *file_out = stdout;
     81#define FILE_IN stdin
     82#define FILE_OUT stdout
    8083static char line[MAX_LINE_LEN + 1];
    8184
     
    147150      if (res == 0)
    148151    {
    149       fprintf (file_out, "\n***Parsed Expression***\n");
    150       PrintBoolTree (tree, file_out);
    151       fputc ('\n', file_out);
     152      fprintf (FILE_OUT, "\n***Parsed Expression***\n");
     153      PrintBoolTree (tree, FILE_OUT);
     154      fputc ('\n', FILE_OUT);
    152155      OptimiseBoolTree (tree, term_list, opt_type);
    153       fprintf (file_out, "\n***Optimised Expression ***\n");
    154       PrintBoolTree (tree, file_out);
    155       fputc ('\n', file_out);
     156      fprintf (FILE_OUT, "\n***Optimised Expression ***\n");
     157      PrintBoolTree (tree, FILE_OUT);
     158      fputc ('\n', FILE_OUT);
    156159    }
    157160
     
    170173prompt (char *str)
    171174{
    172   fprintf (file_out, "\n%s\n", str);
    173   return fgets (line, MAX_LINE_LEN, file_in);
     175  fprintf (FILE_OUT, "\n%s\n", str);
     176  return fgets (line, MAX_LINE_LEN, FILE_IN);
    174177}
  • trunk/gsdl/src/mgpp/text/bool_tree.cpp

    r655 r711  
    4141{
    4242  bool_tree_node *n;
    43   if (!(n = (bool_tree_node *) Xmalloc (sizeof (bool_tree_node))))
     43  if (!(n = new bool_tree_node))
    4444    FatalError (1, "Can not create bool_tree_node for boolean query");
    4545  n->tag = tag;
     
    125125    FreeTree (BOOL_CHILD (tree));
    126126      sibling = BOOL_SIBLING (tree);
    127       Xfree (tree);
     127      delete (tree);
    128128      tree = sibling;
    129129    }
  • trunk/gsdl/src/mgpp/text/commands.cpp

    r655 r711  
    2424/*
    2525   $Log$
     26   Revision 1.2  1999/10/17 23:43:24  cs025
     27   Changes to eradicate Xmalloc
     28
    2629   Revision 1.1  1999/10/11 02:57:08  cs025
    2730   Base install of MG-PP
     
    241244
    242245  /* join the two parameters together */
    243   buf = (char *) Xmalloc (strlen (param1) + strlen (param2) + 1);
     246  buf = new char[strlen (param1) + strlen (param2) + 1];
    244247  strcpy (buf, param1);
    245248  strcat (buf, param2);
     
    268271      InPipe = 0;
    269272      InFile = stdin;
    270       Xfree (buf);
     273      delete buf;
    271274      return;
    272275    }
     
    303306      InFile = stdin;
    304307    }
    305   Xfree (buf);
     308  delete buf;
    306309}
    307310
     
    320323
    321324  /* join the two parameters together */
    322   buf = (char *) Xmalloc (strlen (param1) + strlen (param2) + 1);
     325  buf = new char[strlen (param1) + strlen (param2) + 1];
    323326  strcpy (buf, param1);
    324327  strcat (buf, param2);
     
    350353      OutPipe = 0;
    351354      OutFile = stdout;
    352       Xfree (buf);
     355      delete buf;
    353356      return;
    354357    }
     
    384387      OutFile = stdout;
    385388    }
    386   Xfree (buf);
     389  delete buf;
    387390}
    388391
  • trunk/gsdl/src/mgpp/text/grbIndex.cpp

    r659 r711  
    2424/*
    2525   $Log$
     26   Revision 1.4  1999/10/17 23:43:24  cs025
     27   Changes to eradicate Xmalloc
     28
    2629   Revision 1.3  1999/10/12 04:13:11  cs025
    2730   Changes made to eradicate use of GetEnv elsewhere.
     
    184187    {
    185188      if (Stats[i].name)
    186         Xfree (Stats[i].name);
     189        delete Stats[i].name;
    187190      if (Stats[i].text)
    188         Xfree (Stats[i].text);
     191        delete Stats[i].text;
    189192    }
    190193      Xfree (Stats);
     
    483486  if (post_proc)
    484487    {
    485       Xfree (post_proc);
     488      delete post_proc;
    486489      post_proc = NULL;
    487490    }
     
    940943  if (OutputType == OUTPUT_TEXT || OutputType == OUTPUT_HILITE)
    941944    {
    942       Xfree (doc_sepstr);
    943       Xfree (para_sepstr);
    944       Xfree (para_start);
     945      delete doc_sepstr;
     946      delete para_sepstr;
     947      delete para_start;
    945948    }
    946949
     
    955958  de_escape_string (terminator);
    956959  fputs (terminator, out);
    957   Xfree (terminator);
     960  delete terminator;
    958961}
    959962
  • 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;
  • trunk/gsdl/src/mgpp/text/mgdictlist.cpp

    r655 r711  
    3737/*
    3838   $Log$
     39   Revision 1.2  1999/10/17 23:43:27  cs025
     40   Changes to eradicate Xmalloc
     41
    3942   Revision 1.1  1999/10/11 02:58:08  cs025
    4043   Base install of MG-PP
     
    195198          cfh.hd.maxcodelen, code, word2str (prev));
    196199    }
    197   Xfree (codes);
    198   Xfree (cfh.hd.clens);
     200  delete codes;
     201  delete cfh.hd.clens;
    199202}
    200203
     
    232235      }
    233236      }
    234   Xfree (codes);
    235   Xfree (hd.clens);
     237  delete codes;
     238  delete hd.clens;
    236239}
    237240
  • trunk/gsdl/src/mgpp/text/mgquery.cpp

    r658 r711  
    2424/*
    2525   $Log$
     26   Revision 1.4  1999/10/17 23:43:28  cs025
     27   Changes to eradicate Xmalloc
     28
    2629   Revision 1.3  1999/10/12 04:12:46  cs025
    2730   Changes made to assist with eradication of GetEnv elsewhere in the
     
    187190    {
    188191      if (Stats[i].name)
    189         Xfree (Stats[i].name);
     192        delete Stats[i].name;
    190193      if (Stats[i].text)
    191         Xfree (Stats[i].text);
     194        delete Stats[i].text;
    192195    }
    193196      Xfree (Stats);
     
    486489  if (post_proc)
    487490    {
    488       Xfree (post_proc);
     491      delete post_proc;
    489492      post_proc = NULL;
    490493    }
     
    965968  if (OutputType == OUTPUT_TEXT || OutputType == OUTPUT_HILITE)
    966969    {
    967       Xfree (doc_sepstr);
    968       Xfree (para_sepstr);
    969       Xfree (para_start);
     970      delete doc_sepstr;
     971      delete para_sepstr;
     972      delete para_start;
    970973    }
    971974
     
    980983  de_escape_string (terminator);
    981984  fputs (terminator, out);
    982   Xfree (terminator);
     985  delete terminator;
    983986}
    984987
  • trunk/gsdl/src/mgpp/text/query.ranked.cpp

    r660 r711  
    5151/*
    5252   $Log$
     53   Revision 1.3  1999/10/17 23:43:29  cs025
     54   Changes to eradicate Xmalloc
     55
    5356   Revision 1.2  1999/10/12 04:13:52  cs025
    5457   Calls to GetEnv eradicated; interface to parsing of query text
     
    128131    int MaxSize;
    129132    HeapComp HC;
    130     HeapEntry HE[1];
     133    HeapEntry *HE;
     134
     135    Heap(int size)
     136    {
     137      HE = new HeapEntry[size];
     138    }
     139
     140    ~Heap()
     141    {
     142      if (HE != NULL)
     143    delete HE;
     144    }
    131145  }
    132146Heap;
     
    137151{
    138152  Heap *H;
    139   H = (Heap *) Xmalloc (sizeof (Heap) + (size - 1) * sizeof (HeapEntry));
     153  H = new Heap(size);
    140154  if (!H)
    141155    return NULL;
     
    644658     document weights which we retrieve from the ".idx.wgt" file and put
    645659     the resulting data into a heap */
    646 
    647 
    648660  he = H->HE;
    649661  H->NumItems = MaxDocs;
     
    805817    }
    806818
    807 
    808819  if (rqi->Exact && qd->id->ifh.InvfLevel != 3)
    809820    {
     
    957968    }
    958969    }
    959 
    960 
    961970
    962971  H->HC = Heap_Greater;
     
    10621071    LT_free (qd, LT);
    10631072
    1064   if (H) Xfree (H); /* [RJM 07/98: Memory Leak] */
     1073  if (H) delete H; /* [RJM 07/98: Memory Leak] */
    10651074
    10661075  return (Docs);
  • trunk/gsdl/src/mgpp/text/read_line.cpp

    r655 r711  
    8383static void memory_error_and_abort ();
    8484
    85 char *
    86 xmalloc (bytes)
    87      int bytes;
    88 {
    89   char *temp = (char *) Xmalloc (bytes);
     85void *
     86xmalloc (size_t bytes)
     87{
     88  void *temp = Xmalloc (bytes);
    9089
    9190  if (!temp)
     
    9493}
    9594
    96 char *
    97 xrealloc (pointer, bytes)
    98      char *pointer;
    99      int bytes;
    100 {
    101   char *temp;
     95void *
     96xrealloc (void *pointer, size_t bytes)
     97{
     98  void *temp;
    10299
    103100  if (!pointer)
    104     temp = (char *) xmalloc (bytes);
     101    temp = xmalloc (bytes);
    105102  else
    106     temp = (char *) Xrealloc (pointer, bytes);
     103    temp = Xrealloc (pointer, bytes);
    107104
    108105  if (!temp)
     
    150147  static char *the_line = NULL;
    151148  if (the_line)
    152     Xfree (the_line);
     149    delete the_line;
    153150  the_line = NULL;
    154151  rl_instream = InFile;
     
    194191  char *s;
    195192  if (line)
    196     Xfree (line);
     193    delete line;
    197194  line = NULL;
     195
    198196  if (!(s = GetLine ("> ")))
    199197    return (NULL);
     
    210208      if (!(s = GetLine ("? ")))
    211209    return (NULL);
    212       if (!(newline = (char *) Xmalloc (strlen (line) + strlen (s) + 2)))
     210      if (!(newline = new char[strlen (line) + strlen (s) + 2]))
    213211    {
    214212      fprintf (stderr, "Unable to allocate memory for the line\n");
     
    218216      strcat (newline, "\n");
    219217      strcat (newline, s);
    220       Xfree (line);
     218      delete line;
    221219      line = newline;
    222220    }
  • trunk/gsdl/src/mgpp/text/stem_search.cpp

    r655 r711  
    4848/*
    4949   $Log$
     50   Revision 1.2  1999/10/17 23:43:29  cs025
     51   Changes to eradicate Xmalloc
     52
    5053   Revision 1.1  1999/10/11 02:58:32  cs025
    5154   Base install of MG-PP
     
    108111      return (NULL);
    109112    }
    110   /*
    111   si->stem_idx_file = stem_idx_file;
    112   si->MemForStemIdx = 0;
    113 
    114   Fread (&si->sih, sizeof (si->sih), 1, stem_idx_file);
    115   // [RPAP - Jan 97: Endian Ordering]
    116   NTOHUL(si->sih.lookback);
    117   NTOHUL(si->sih.block_size);
    118   NTOHUL(si->sih.num_blocks);
    119   NTOHUL(si->sih.blocks_start);
    120   NTOHUL(si->sih.index_chars);
    121   NTOHUL(si->sih.num_of_words);
    122 
    123   if (!(buffer = (u_char *) Xmalloc (si->sih.index_chars)))
    124     {
    125       Xfree (si);
    126       mg_errno = MG_NOMEM;
    127       return (NULL);
    128     };
    129   si->MemForStemIdx += si->sih.index_chars;
    130 
    131   if (!(si->index = (u_char **) Xmalloc (si->sih.num_blocks * sizeof (*si->index))))
    132     {
    133       Xfree (si);
    134       Xfree (buffer);
    135       mg_errno = MG_NOMEM;
    136       return (NULL);
    137     };
    138   si->MemForStemIdx += si->sih.num_blocks * sizeof (*si->index);
    139 
    140   if (!(si->pos = (long unsigned int *) Xmalloc (si->sih.num_blocks * sizeof (*si->pos))))
    141     {
    142       Xfree (si->index);
    143       Xfree (si);
    144       Xfree (buffer);
    145       mg_errno = MG_NOMEM;
    146       return (NULL);
    147     };
    148   si->MemForStemIdx += si->sih.num_blocks * sizeof (*si->pos);
    149 
    150   if (!(si->buffer = (u_char *) Xmalloc (si->sih.block_size * sizeof (*si->buffer))))
    151     {
    152       Xfree (buffer);
    153       Xfree (si->index);
    154       Xfree (si->buffer);
    155       Xfree (si);
    156       mg_errno = MG_NOMEM;
    157       return (NULL);
    158     };
    159   si->MemForStemIdx += si->sih.block_size * sizeof (*si->buffer);
    160 
    161   si->active = -1;
    162 
    163   for (i = 0; i < si->sih.num_blocks; i++)
    164     {
    165       register u_char len;
    166       si->index[i] = buffer;
    167       len = Getc (stem_idx_file);
    168       *buffer++ = len;
    169       Fread (buffer, sizeof (u_char), len, stem_idx_file);
    170       buffer += len;
    171       Fread (&si->pos[i], sizeof (*si->pos), 1, stem_idx_file);
    172       NTOHUL(si->pos[i]);  // [RPAP - Jan 97: Endian Ordering]
    173     }
    174   */
    175113  mg_errno = MG_NOERROR;
    176114
     
    300238      StemBlock_read(sd, block, &first_word, &last_invf_len, &num_words,
    301239             &index, &num_indexes);
    302       /*      int i;
    303 
    304       Fseek (sd->stem_file, sd->pos[block] + sd->sdh.blocks_start, 0);
    305       Fread (sd->buffer, sd->sdh.block_size, sizeof (u_char), sd->stem_file);
    306       sd->active = sd->pos[block];
    307 
    308       // [RPAP - Jan 97: Endian Ordering]
    309       first_word = (unsigned long *) (sd->buffer);
    310       NTOHUL(*first_word);
    311       last_invf_len = (unsigned long *) (first_word + 1);
    312       NTOHUL(*last_invf_len);
    313       num_words = (unsigned short *) (last_invf_len + 1);
    314       NTOHUS(*num_words);
    315       index = num_words + 1;
    316       num_indexes = ((*num_words - 1) / sd->sdh.lookback) + 1;
    317 
    318       for (i = 0; i < num_indexes; i++)
    319       NTOHUS(index[i]);*/
    320240    }
    321241  else
     
    334254  */
    335255  hi = Word_BaseIndexNo(num_indexes, base, index, Word);
    336   /*
    337   lo = 0;
    338   hi = num_indexes - 1;
    339   while (lo <= hi)
    340     {
    341       mid = (lo + hi) / 2;
    342       c = casecompare (Word, base + index[mid] + 1);  // [RPAP - Jan 97: Stem Index Change]
    343       if (c < 0)
    344     hi = mid - 1;
    345       else if (c > 0)
    346     lo = mid + 1;
    347       else
    348     {
    349       hi = mid;
    350       break;
    351     }
    352     }
    353   if (hi < 0)
    354     hi = 0;
    355   */
    356256
    357257  res = hi * sd->sdh.lookback;
     
    365265  while (res < *num_words)
    366266    {
    367       //unsigned copy, suff;
    368267      unsigned long invfp;
    369       /*      if (res >= *num_words)
    370           return (-1);*/
    371268      StemBlock_ReadWordString(&base, prev);
    372       /*     
    373       copy = *base++;
    374       suff = *base++;
    375       bcopy ((void *) base, (void *) (prev + copy + 1), suff);
    376       base += suff;
    377       *prev = copy + suff;
    378       */
    379269
    380270      c = casecompare (Word, prev);   /* [RPAP - Jan 97: Stem Index Change] */
     
    407297    {
    408298      /* Calculate invf_len is necessary */
    409       // unsigned long next_invfp;
    410299      if (!invf_len)
    411300        return (*first_word + res);
     
    421310      /* Skip over most of the next word to get to the invf_ptr */
    422311      *invf_len = Word_SkipToNextInvfPtr(&base, invfp);
    423       /*
    424       base++;
    425       suff = *base++;
    426       base += suff + sizeof (unsigned long) * 2;
    427       bcopy ((void *) base, (void *) &next_invfp, sizeof (next_invfp));
    428       NTOHUL(next_invfp);  // [RPAP - Jan 97: Endian Ordering]
    429       *invf_len = next_invfp - invfp;
    430       */
    431312      return (*first_word + res);
    432313    }
     
    507388      StemIdx_block_readNext((void *) si->stem_idx_file, si, idx_block, &idx_first_word, &idx_num_words,
    508389                 &idx_index, &idx_num_indexes, stemAbstractSeeker, stemAbstractReader);
    509       /*
    510       Fseek (si->stem_idx_file, si->pos[idx_block] + si->sih.blocks_start, 0);
    511       Fread (si->buffer, si->sih.block_size, sizeof (u_char), si->stem_idx_file);
    512       si->active = si->pos[idx_block];
    513 
    514       idx_first_word = (unsigned long *) (si->buffer);
    515       NTOHUL(*idx_first_word);  // [RPAP - Jan 97: Endian Ordering]
    516       idx_num_words = (unsigned short *) (idx_first_word + 1);
    517       NTOHUS(*idx_num_words);  // [RPAP - Jan 97: Endian Ordering]
    518       idx_index = idx_num_words + 1;
    519       idx_num_indexes = ((*idx_num_words - 1) / si->sih.lookback) + 1;
    520 
    521       // [RPAP - Jan 97: Endian Ordering]
    522       for (j = 0; j < idx_num_indexes; j++)
    523     NTOHUS(idx_index[j]);
    524       */
    525390    }
    526391  else
     
    542407
    543408    hi = Word_BaseIndexNo(idx_num_indexes, idx_base, idx_index, sWord);
    544     /*
    545     lo = 0;
    546     hi = idx_num_indexes - 1;
    547     while (lo <= hi)
    548       {
    549     mid = (lo + hi) / 2;
    550     c = casecompare (sWord, idx_base + idx_index[mid] + 1);
    551     if (c < 0)
    552       hi = mid - 1;
    553     else if (c > 0)
    554       lo = mid + 1;
    555     else
    556       {
    557         hi = mid;
    558         break;
    559       }
    560       }
    561     if (hi < 0)
    562       hi = 0;
    563     */
    564409    idx_res = hi * si->sih.lookback;
    565410    idx_base += idx_index[hi];
     
    573418    return (-1);
    574419      StemIdx_ReadWordString(&idx_base, idx_prev);
    575 
    576       /*
    577       copy = *idx_base++;
    578       suff = *idx_base++;
    579       bcopy ((void *) idx_base, (void *) (idx_prev + copy + 1), suff);
    580       idx_base += suff;
    581       *idx_prev = copy + suff;
    582       */
    583420
    584421      c = casecompare (sWord, idx_prev);
     
    608445       */
    609446      StemIdx_ReadPosEntry(&idx_base, &num_cases, (unsigned int *) &block, &blk_index, &offset);
    610       /*
    611       bcopy ((void *) idx_base, (void *) &num_cases, sizeof (num_cases));
    612       NTOHUI(num_cases);  // [RPAP - Jan 97: Endian Ordering]
    613       idx_base += sizeof (num_cases);
    614       bcopy ((void *) idx_base, (void *) &block, sizeof (block));
    615       NTOHUI(block);  // [RPAP - Jan 97: Endian Ordering]
    616       idx_base += sizeof (block);
    617       bcopy ((void *) idx_base, (void *) &blk_index, sizeof (blk_index));
    618       NTOHUS(blk_index);  // [RPAP - Jan 97: Endian Ordering]
    619       idx_base += sizeof (blk_index);
    620       bcopy ((void *) idx_base, (void *) &offset, sizeof (offset));
    621       NTOHUS(offset);  // [RPAP - Jan 97: Endian Ordering]
    622       idx_base += sizeof (offset);
    623       */
    624447     
    625448
     
    636459      StemBlock_read(sd, block, &first_word, &last_invf_len, &num_words,
    637460             &index, &num_indexes);
    638       /*
    639       Fseek (sd->stem_file, sd->pos[block] + sd->sdh.blocks_start, 0);
    640       Fread (sd->buffer, sd->sdh.block_size, sizeof (u_char), sd->stem_file);
    641       sd->active = sd->pos[block];
    642 
    643       first_word = (unsigned long *) (sd->buffer);
    644       NTOHUL(*first_word);  // [RPAP - Jan 97: Endian Ordering]
    645       last_invf_len = (unsigned long *) (first_word + 1);
    646       NTOHUL(*last_invf_len);  // [RPAP - Jan 97: Endian Ordering]
    647       num_words = (unsigned short *) (last_invf_len + 1);
    648       NTOHUS(*num_words);  // [RPAP - Jan 97: Endian Ordering]
    649       index = num_words + 1;
    650       num_indexes = ((*num_words - 1) / sd->sdh.lookback) + 1;
    651 
    652       // [RPAP - Jan 97: Endian Ordering]
    653       for (j = 0; j < num_indexes; j++)
    654         NTOHUS(index[j]);
    655       */
    656461    }
    657462      else
     
    676481      StemBlock_ReadWordString(&base, prev);
    677482     
    678       /*
    679       copy = *base++;
    680       suff = *base++;
    681       bcopy ((void *) base, (void *) (prev + copy + 1), suff);
    682       base += suff;
    683       *prev = copy + suff;
    684       */
    685483      base += sizeof (unsigned long);   /* skip doc_count */
    686484      base += sizeof (unsigned long);   /* skip count */
     
    699497        return (-1);
    700498      StemBlock_ReadWordString(&base, prev);
    701       /*
    702       copy = *base++;
    703       suff = *base++;
    704       bcopy ((void *) base, (void *) (prev + copy + 1), suff);
    705       base += suff;
    706       *prev = copy + suff;
    707       */
    708499         
    709500      te.Word = copy_string (prev);
     
    737528      else
    738529        {
    739           //unsigned long next_invfp;
    740530          u_char *oldbase = base;
    741531         
    742532          /* Skip over most of the next word to get to the invf_ptr */
    743533          te.WE.invf_len = Word_SkipToNextInvfPtr(&base, invfp);
    744           /*
    745           base++;
    746           suff = *base++;
    747           base += suff + sizeof (unsigned long) * 2;
    748           bcopy ((void *) base, (void *) &next_invfp, sizeof (next_invfp));
    749           NTOHUL(next_invfp);  // [RPAP - Jan 97: Endian Ordering]
    750           te.WE.invf_len = next_invfp - invfp;
    751           */
    752534          base = oldbase;
    753535        }
     
    764546      if (res == *num_words - 1 && j + 1 < num_cases)
    765547        {
    766           //int ii;
    767548          /* Read in next block */
    768549          block++;
    769550          StemBlock_read(sd, block, &first_word, &last_invf_len, &num_words,
    770551                 &index, &num_indexes);
    771           /*
    772           Fseek (sd->stem_file, sd->pos[block] + sd->sdh.blocks_start, 0);
    773           Fread (sd->buffer, sd->sdh.block_size, sizeof (u_char), sd->stem_file);
    774           sd->active = sd->pos[block];
    775 
    776           first_word = (unsigned long *) (sd->buffer);
    777           NTOHUL(*first_word);  // [RPAP - Jan 97: Endian Ordering]
    778           last_invf_len = (unsigned long *) (first_word + 1);
    779           NTOHUL(*last_invf_len);  // [RPAP - Jan 97: Endian Ordering]
    780           num_words = (unsigned short *) (last_invf_len + 1);
    781           NTOHUS(*num_words);  // [RPAP - Jan 97: Endian Ordering]
    782           index = num_words + 1;
    783           num_indexes = ((*num_words - 1) / sd->sdh.lookback) + 1;
    784 
    785           // [RPAP - Jan 97: Endian Ordering]
    786           for (ii = 0; ii < num_indexes; ii++)
    787         NTOHUS(index[ii]);
    788           */
    789552          base = (u_char *) (index + num_indexes);
    790553          base += index[0];
     
    811574    FreeStemIdx (sd->stem3);
    812575
    813   Xfree (sd->index[0]);
    814   Xfree (sd->index);
    815   Xfree (sd->buffer);
    816   Xfree (sd->pos);
    817   Xfree (sd);
     576  delete (sd->index[0]);
     577  delete (sd->index);
     578  delete (sd->buffer);
     579  delete (sd->pos);
     580  delete sd;
    818581}
    819582
     
    822585FreeStemIdx (stemmed_idx * si)
    823586{
    824   Xfree (si->index[0]);
    825   Xfree (si->index);
    826   Xfree (si->buffer);
    827   Xfree (si->pos);
    828   Xfree (si);
    829 }
     587  delete si->index[0];
     588  delete si->index;
     589  delete si->buffer;
     590  delete si->pos;
     591  delete si;
     592}
  • trunk/gsdl/src/mgpp/text/text_get.cpp

    r655 r711  
    5151/*
    5252   $Log$
     53   Revision 1.2  1999/10/17 23:43:30  cs025
     54   Changes to eradicate Xmalloc
     55
    5356   Revision 1.1  1999/10/11 02:58:39  cs025
    5457   Base install of MG-PP
     
    6871   *
    6972 */
     73
     74typedef enum huff_type {lengths, chars};
    7075
    7176static char *RCSID = "$Id$";
     
    113118  if (!td->idx_data)
    114119    {
    115       td->idx_data = (__idx_data *) Xmalloc (sizeof (*(td->idx_data)) * MG_PAGE_SIZE);
     120      td->idx_data = new index_data[MG_PAGE_SIZE];
    116121      if (!td->idx_data)
    117122    FatalError (1, "Out of memory in FDSL2");
    118123    }
     124
    119125  if (td->current_pos == -1 || DN >= td->current_pos + MG_PAGE_SIZE - 1 ||
    120126      DN < td->current_pos)
     
    125131      if (rn < 1)
    126132    rn = 1;
     133
    127134      Fseek (td->TextIdxWgtFile, (sizeof (unsigned long) + sizeof (float)) *
    128135           (rn - 1) + sizeof (unsigned long), 0);
     136
    129137      num = Fread ((char *) td->idx_data, sizeof (*(td->idx_data)), MG_PAGE_SIZE, /* [RPAP - Jan 97: Endian Ordering] */
    130138           td->TextIdxWgtFile);
     
    219227    DocEnt->FetchStart(qd);
    220228  //    FetchDocStart (qd, DocEnt->DocNum, &DocEnt->SeekPos, &DocEnt->Len);
    221   if (!(*DocBuff = (char *) Xmalloc (DocEnt->Len)))
     229  if (!(*DocBuff = new char[DocEnt->Len]))
    222230    return (-1);
    223231
     
    240248  text_data *td;
    241249
    242   if (!(td = (text_data *) Xmalloc (sizeof (text_data))))
     250  if (!(td = new text_data))
    243251    {
    244252      mg_errno = MG_NOMEM;
     
    270278    {
    271279      if (td->idx_data)
    272     Xfree (td->idx_data);
    273       Xfree (td);
     280    delete td->idx_data;
     281      delete td;
    274282    }
    275283}
     
    292300  DocEntry **pts;
    293301  int i, j;
    294   if (!(pts = (DocEntry **) Xmalloc (num * sizeof (DocEntry *))))
     302  if (!(pts = new (DocEntry *)[num]))
    295303    {
    296304      mg_errno = MG_NOMEM;
     
    309317    }
    310318
    311   Xfree (pts);
     319  delete pts;
    312320  return (0);
    313321}
     
    326334  if (!num)
    327335    return (0);
    328   if (!(pts = (DocEntry **) Xmalloc (num * sizeof (DocEntry *))))
     336  if (!(pts = new (DocEntry *)[num]))
    329337    {
    330338      mg_errno = MG_NOMEM;
     
    350358    }
    351359
    352   Xfree (pts);
     360  delete pts;
    353361
    354362  return (i);
     
    369377    if (Docs->CompTextBuffer)
    370378      {
    371     Xfree (Docs->CompTextBuffer);
     379    delete Docs->CompTextBuffer;
    372380    Docs->CompTextBuffer = NULL;
    373381    ChangeMemInUse (qd, -Docs->Len);
     
    386394    return;
    387395  if (ad->word_data[0])
    388     Xfree (ad->word_data[0]);
     396    delete ad->word_data[0];
    389397  if (ad->word_data[1])
    390     Xfree (ad->word_data[1]);
     398    delete ad->word_data[1];
    391399  if (ad->words[0])
    392     Xfree (ad->words[0]);
     400    delete ad->words[0];
    393401  if (ad->words[1])
    394     Xfree (ad->words[1]);
    395   Xfree (ad);
     402    delete ad->words[1];
     403  delete ad;
    396404}
    397405
     
    402410  int i;
    403411
    404   if (!(ad = (auxiliary_dict *) Xmalloc (sizeof (auxiliary_dict))))
     412  if (!(ad = new auxiliary_dict))
    405413    {
    406414      mg_errno = MG_NOMEM;
     
    421429      NTOHUL(ad->afh[i].mem_for_frags);
    422430
    423       if (!(ad->word_data[i] = (u_char *) Xmalloc (ad->afh[i].mem_for_frags)))
     431      if (!(ad->word_data[i] = new u_char[ad->afh[i].mem_for_frags]))
    424432    {
    425433      mg_errno = MG_NOMEM;
     
    427435      return (NULL);
    428436    }
    429       if (!(ad->words[i] = (u_char **) Xmalloc (ad->afh[i].num_frags * sizeof (u_char *))))
     437      if (!(ad->words[i] = new (u_char *)[ad->afh[i].num_frags]))
    430438    {
    431439      mg_errno = MG_NOMEM;
     
    489497    }
    490498
    491   if (!(vals = (u_char **) Xmalloc (ptrs_reqd * sizeof (*vals))))
     499  if (!(vals = new (u_char *)[ptrs_reqd]))
    492500    return (NULL);
    493501
    494   if (!(values = (u_char ***) Xmalloc ((MAX_HUFFCODE_LEN + 1) * sizeof (u_char **))))
     502  if (!(values = new (u_char **)[MAX_HUFFCODE_LEN + 1]))
    495503    return (NULL);
    496504
    497   if (!(next_word[0] = (u_char *) Xmalloc (mem_reqd))) return (NULL);
     505  if (!(next_word[0] = new u_char[mem_reqd]))
     506    return (NULL);
    498507
    499508  cd->MemForCompDict += ptrs_reqd * sizeof (*vals) +
     
    546555    }
    547556  if (cfh->hd.clens)
    548     Xfree (cfh->hd.clens);
     557    delete cfh->hd.clens;
    549558  cfh->hd.clens = NULL;
    550559  return values;
    551560}
    552561
    553 int Load_Comp_HuffData(compression_dict *cd, int which, File *dict)
     562int Load_Comp_HuffData(compression_dict *cd, int which, File *dict,
     563               huff_type type)
    554564{
    555565  huff_data * hd;
    556566  u_long **   vals;
    557567
    558   if (!(hd = (huff_data *) Xmalloc (sizeof (huff_data))))
     568  if (!(hd = new huff_data))
    559569    return 1;
    560570  cd->MemForCompDict += sizeof (huff_data);
     
    564574    return 3;
    565575  if (hd->clens)
    566     Xfree (hd->clens);
     576    delete hd->clens;
    567577  hd->clens = NULL;
    568   cd->chars_huff[which] = hd;
    569   cd->chars_vals[which] = vals;
     578  if (type == chars)
     579    {
     580      cd->chars_huff[which] = hd;
     581      cd->chars_vals[which] = vals;
     582    }
     583  else
     584    {
     585      cd->lens_huff[which] = hd;
     586      cd->lens_vals[which] = vals;
     587    }
    570588
    571589  return 0;
     
    574592int Load_Comp_FragsHeader(compression_dict *cd, int which, int getEscape, File *dict)
    575593{
    576   if (!(cd->cfh[which] = (comp_frags_header *) Xmalloc (sizeof (*cd->cfh[which]))))
     594  if (!(cd->cfh[which] = new comp_frags_header))
    577595    return 1;
    578596  cd->MemForCompDict += sizeof (*cd->cfh[which]);
     
    592610  compression_dict *cd;
    593611
    594   if (!(cd = (compression_dict *) Xmalloc (sizeof (compression_dict))))
     612  if (!(cd = new compression_dict))
    595613    {
    596614      mg_errno = MG_NOMEM;
     
    647665          */
    648666        }
    649       if (Load_Comp_HuffData(cd, which, dict) != 0)
     667      if (Load_Comp_HuffData(cd, which, dict, chars) != 0)
    650668        return NULL;
    651669      /*
     
    663681      cd->chars_vals[which] = vals;
    664682      */
    665       if (Load_Comp_HuffData(cd, which, dict) != 0)
     683      if (Load_Comp_HuffData(cd, which, dict, lengths) != 0)
    666684        return NULL;
    667685      /*
     
    704722        {
    705723        case MG_NOVEL_HUFFMAN_CHARS:
    706           if (Load_Comp_HuffData(cd, which, dict) != 0)
     724          if (Load_Comp_HuffData(cd, which, dict, chars) != 0)
    707725        return NULL;
    708726          /*
    709727          if (!(hd = (huff_data *) Xmalloc (sizeof (huff_data))))
    710728        return NULL;
    711           cd->chars_huff[which] = hd;
    712729          cd->MemForCompDict += sizeof (huff_data);
    713730          if (F_Read_Huffman_Data (dict, hd, &cd->MemForCompDict,
     
    716733          if (!(vals = Generate_Huffman_Vals (hd, &cd->MemForCompDict)))
    717734        return NULL;
     735          cd->chars_huff[which] = hd;
    718736          cd->chars_vals[which] = vals;
    719737          if (hd->clens)
     
    722740          */
    723741
    724           if (Load_Comp_HuffData(cd, which, dict) != 0)
     742          if (Load_Comp_HuffData(cd, which, dict, lengths) != 0)
    725743        return NULL;
    726744          /*
     
    728746        return NULL;
    729747          cd->MemForCompDict += sizeof (huff_data);
    730           cd->lens_huff[which] = hd;
    731748          if (F_Read_Huffman_Data (dict, hd, &cd->MemForCompDict
    732749                       ,NULL) == -1)
     
    734751          if (!(vals = Generate_Huffman_Vals (hd, &cd->MemForCompDict)))
    735752        return NULL;
     753          cd->lens_huff[which] = hd;
    736754          cd->lens_vals[which] = vals;
    737755          if (hd->clens)
     
    807825  Fread (cd, sizeof (u_char), mem, text_fast_comp_dict);
    808826
    809   if (!(fixup = (u_char *) Xmalloc (fixup_mem)))
     827  if (!(fixup = new u_char[fixup_mem]))
    810828    {
    811829      mg_errno = MG_NOMEM;
     
    870888  NTOHSI(cd->fast_loaded);
    871889
    872   Xfree (fixup);
     890  delete fixup;
    873891  return (cd);
    874892}
     
    897915  if (cd->fast_loaded)
    898916    {
    899       Xfree (cd);
     917      delete cd;
    900918      return;
    901919    }
     
    903921    {
    904922      if (cd->cfh[which])
    905     Xfree (cd->cfh[which]);
     923    delete cd->cfh[which];
    906924      if (cd->chars_huff[which])
    907     Xfree (cd->chars_huff[which]);
     925    delete cd->chars_huff[which];
    908926      if (cd->lens_huff[which])
    909     Xfree (cd->lens_huff[which]);
     927    delete cd->lens_huff[which];
    910928      if (cd->values[which])
    911929    {
    912       Xfree (cd->values[which][0][0]); /* [RJM 07/98: Memory Leak] */
    913       Xfree (cd->values[which][0]);
    914       Xfree (cd->values[which]);
     930      delete (cd->values[which][0][0]); /* [RJM 07/98: Memory Leak] */
     931      delete cd->values[which][0];
     932      delete (cd->values[which]);
    915933    }
    916934      if (cd->chars_vals[which])
    917935    {
    918       Xfree (cd->chars_vals[which][0]);
    919       Xfree (cd->chars_vals[which]);
     936      delete cd->chars_vals[which][0];
     937      delete cd->chars_vals[which];
    920938    }
    921939      if (cd->lens_vals[which])
    922940    {
    923       Xfree (cd->lens_vals[which][0]);
    924       Xfree (cd->lens_vals[which]);
     941      delete cd->lens_vals[which][0];
     942      delete cd->lens_vals[which];
    925943    }
    926944    }
    927945  if (cd->ad)
    928946    FreeAuxDict (cd->ad);
    929   Xfree (cd);
     947  delete cd;
    930948}
    931949
  • trunk/gsdl/src/mgpp/text/weights.cpp

    r655 r711  
    4343/*
    4444   $Log$
     45   Revision 1.2  1999/10/17 23:43:31  cs025
     46   Changes to eradicate Xmalloc
     47
    4548   Revision 1.1  1999/10/11 02:58:41  cs025
    4649   Base install of MG-PP
     
    6871  int num;
    6972
    70   if (!(awd = (approx_weights_data *) Xmalloc (sizeof (*awd))))
     73  if (!(awd = new approx_weights_data))
    7174    {
    7275      mg_errno = MG_NOMEM;
     
    8487
    8588  num = (num_of_docs * awd->bits + 31) / 32;
    86   if (!(awd->DocWeights = (long unsigned int *) Xmalloc (sizeof (unsigned long) * num)))
     89  if (!(awd->DocWeights = new (unsigned long)[num]))
    8790    {
    88       Xfree (awd);
     91      delete awd;
    8992      mg_errno = MG_NOMEM;
    9093      return (NULL);
     
    107110    {
    108111      int i, size = (1 << awd->bits);
    109       if (!(awd->table = (float *) Xmalloc (size * sizeof (float))))
     112      if (!(awd->table = new float[size]))
    110113      return (awd);
    111114      awd->table[0] = awd->L;
     
    155158FreeWeights (approx_weights_data * awd)
    156159{
    157   Xfree (awd->DocWeights);
     160  delete (awd->DocWeights);
    158161  if (awd->table)
    159     Xfree (awd->table);
    160   Xfree (awd);
     162    delete (awd->table);
     163  delete awd;
    161164}
    162165
Note: See TracChangeset for help on using the changeset viewer.