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/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;
Note: See TracChangeset for help on using the changeset viewer.