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