Index: trunk/gsdl/src/mgpp/text/DocEntry.cpp
===================================================================
--- trunk/gsdl/src/mgpp/text/DocEntry.cpp	(revision 710)
+++ trunk/gsdl/src/mgpp/text/DocEntry.cpp	(revision 711)
@@ -40,5 +40,5 @@
   if (de->CompTextBuffer)
   {
-    Xfree (de->CompTextBuffer);
+    delete de->CompTextBuffer;
     de->CompTextBuffer = NULL;
     return de->Len;
Index: trunk/gsdl/src/mgpp/text/StemBlock.cpp
===================================================================
--- trunk/gsdl/src/mgpp/text/StemBlock.cpp	(revision 710)
+++ trunk/gsdl/src/mgpp/text/StemBlock.cpp	(revision 711)
@@ -45,5 +45,5 @@
   int abortvar;
 
-  if (!(sd = (stemmed_dict *) Xmalloc (sizeof (stemmed_dict))))
+  if (!(sd = new stemmed_dict))
     {
       abort(0);
@@ -66,5 +66,5 @@
   NTOHUL(sd->sdh.indexed);
 
-  if (!(buffer = (u_char *) Xmalloc (sd->sdh.index_chars)))
+  if (!(buffer = new u_char[sd->sdh.index_chars]))
     {
       abort(1);
@@ -72,5 +72,5 @@
   sd->MemForStemDict += sd->sdh.index_chars;
 
-  if (!(sd->index = (u_char **) Xmalloc (sd->sdh.num_blocks * sizeof (*sd->index))))
+  if (!(sd->index = new (u_char *)[sd->sdh.num_blocks]))
     {
       abort(2);
@@ -78,5 +78,5 @@
   sd->MemForStemDict += sd->sdh.num_blocks * sizeof (*sd->index);
 
-  if (!(sd->pos = (long unsigned int *) Xmalloc (sd->sdh.num_blocks * sizeof (*sd->pos))))
+  if (!(sd->pos = new (long unsigned int)[sd->sdh.num_blocks]))
     {
       abort(3);
@@ -84,5 +84,5 @@
   sd->MemForStemDict += sd->sdh.num_blocks * sizeof (*sd->pos);
 
-  if (!(sd->buffer = (u_char *) Xmalloc (sd->sdh.block_size * sizeof (*sd->buffer))))
+  if (!(sd->buffer = new u_char[sd->sdh.block_size]))
     {
       abort(4);
@@ -95,4 +95,5 @@
     {
       register u_char len;
+      // Read an MG string from the blocked dictionary
       sd->index[i] = buffer;
       len = Getc (stem_file);
@@ -100,5 +101,8 @@
       Fread (buffer, sizeof (u_char), len, stem_file);
       buffer += len;
+
+      // Read the pointer into the blocks
       Fread (&sd->pos[i], sizeof (*sd->pos), 1, stem_file);
+
       NTOHUL(sd->pos[i]); /* [RPAP - Jan 97: Endian Ordering] */
     }
@@ -114,11 +118,11 @@
     {
       case 4:
-        Xfree (sd->buffer);
+        delete sd->pos;
       case 3:
-        Xfree (sd->index);
+        delete sd->index;
       case 2:
-        Xfree (buffer);
+        delete buffer;
       case 1:
-        Xfree (sd);
+        delete sd;
       break;
 
@@ -158,10 +162,15 @@
 
       /* [RPAP - Jan 97: Endian Ordering] */
+      // first_word is the word number of the first word in the block
       *first_word = (unsigned long *) (sd->buffer);
       NTOHUL(**first_word);
+
       *last_invf_len = (unsigned long *) ((*first_word) + 1);
       NTOHUL(**last_invf_len);
+
+      // num_words is the number of words in the block
       *num_words = (unsigned short *) ((*last_invf_len) + 1);
       NTOHUS(**num_words);
+
       *index = (*num_words) + 1;
       *num_indexes = (((**num_words) - 1) / sd->sdh.lookback) + 1;
Index: trunk/gsdl/src/mgpp/text/StemIdx.cpp
===================================================================
--- trunk/gsdl/src/mgpp/text/StemIdx.cpp	(revision 710)
+++ trunk/gsdl/src/mgpp/text/StemIdx.cpp	(revision 711)
@@ -22,5 +22,5 @@
   int abortvar;
 
-  if (!(si = (stemmed_idx *) Xmalloc (sizeof (stemmed_idx))))
+  if (!(si = new stemmed_idx))
     {
       abort(0);
@@ -43,5 +43,5 @@
   NTOHUL(si->sih.num_of_words);
 
-  if (!(buffer = (u_char *) Xmalloc (si->sih.index_chars)))
+  if (!(buffer = new u_char[si->sih.index_chars]))
     {
       abort(1);
@@ -49,5 +49,5 @@
   si->MemForStemIdx += si->sih.index_chars;
 
-  if (!(si->index = (u_char **) Xmalloc (si->sih.num_blocks * sizeof (*si->index))))
+  if (!(si->index = new (u_char *)[si->sih.num_blocks]))
     {
       abort(2);
@@ -55,5 +55,5 @@
   si->MemForStemIdx += si->sih.num_blocks * sizeof (*si->index);
 
-  if (!(si->pos = (long unsigned int *) Xmalloc (si->sih.num_blocks * sizeof (*si->pos))))
+  if (!(si->pos = new (unsigned long)[si->sih.num_blocks]))
     {
       abort(3);
@@ -61,5 +61,5 @@
   si->MemForStemIdx += si->sih.num_blocks * sizeof (*si->pos);
 
-  if (!(si->buffer = (u_char *) Xmalloc (si->sih.block_size * sizeof (*si->buffer))))
+  if (!(si->buffer = new u_char[si->sih.block_size]))
     {
       abort(4);
@@ -86,11 +86,11 @@
     {
       case 4:
-	Xfree(si->pos);
+	delete si->pos;
       case 3:
-	Xfree(si->index);
+	delete si->index;
       case 2:
-	Xfree(buffer);
+	delete buffer;
       case 1:
-        Xfree(si);
+        delete si;
       break;
     }
Index: trunk/gsdl/src/mgpp/text/backend.cpp
===================================================================
--- trunk/gsdl/src/mgpp/text/backend.cpp	(revision 710)
+++ trunk/gsdl/src/mgpp/text/backend.cpp	(revision 711)
@@ -283,5 +283,5 @@
   if (textname == NULL) textname = name; /* [RJM 06/97: text filename] */
 
-  if (!(qd = (query_data *) Xmalloc (sizeof (query_data))))
+  if (!(qd = new query_data))
     {
       abort(0);
@@ -326,6 +326,6 @@
     {
       /* [RJM 06/97: text filename] */
-      if (!(qd->pathname = (char *) Xmalloc (strlen (dir) + strlen (name) + 1)) ||
-	  !(qd->textpathname = (char *) Xmalloc (strlen (dir) + strlen (textname) + 1)))
+      if (!(qd->pathname = new char[strlen (dir) + strlen (name) + 1]) ||
+	  !(qd->textpathname = new char[strlen (dir) + strlen (textname) + 1]))
 	{
 	  abort(1);
@@ -338,6 +338,6 @@
     {
       /* [RJM 06/97: text filename] */
-      if (!(qd->pathname = (char *) Xmalloc (strlen (dir) + strlen (name) + 2)) ||
-	  !(qd->textpathname = (char *) Xmalloc (strlen (dir) + strlen (textname) + 2)))
+      if (!(qd->pathname = new char[strlen (dir) + strlen (name) + 2]) ||
+	  !(qd->textpathname = new char[strlen (dir) + strlen (textname) + 2]))
 	{
 	  abort(1);
@@ -509,5 +509,5 @@
 
       fread((void *)&magic, sizeof(magic), 1, paragraph);
-      qd->paragraph = Xmalloc((qd->td->cth.num_of_docs+1)*sizeof(int));
+      qd->paragraph = new int[qd->td->cth.num_of_docs+1];
       qd->paragraph[0] = 0;
       for (i = 1; i <= qd->td->cth.num_of_docs; i++)
@@ -545,5 +545,5 @@
     size = ftell (f);
     fseek (f, 0, 0);
-    trec_ids = Xmalloc (size);
+    trec_ids = new char[size];
     if (!trec_ids)
       {
@@ -557,8 +557,8 @@
 	int i, d;
 	unsigned long magic;
-	trec_paras = Xmalloc (qd->sd->sdh.num_of_docs * sizeof (long));
+	trec_paras = new long[qd->sd->sdh.num_of_docs];
 	if (!trec_paras)
 	  {
-	    Xfree (trec_ids);
+	    delete trec_ids;
 	    trec_ids = NULL;
 	    goto error;
@@ -595,7 +595,7 @@
   error:
     if (trec_ids)
-      Xfree (trec_ids);
+      delete trec_ids;
     if (trec_paras)
-      Xfree (trec_paras);
+      delete (trec_paras);
     trec_ids = NULL;
     trec_paras = NULL;
@@ -629,9 +629,9 @@
       close_all_files (qd);
     case 2:
-      Xfree (qd->textpathname); /* [RJM 06/97: text filename] */
+      delete (qd->textpathname); /* [RJM 06/97: text filename] */
     case 1:
       if (qd->pathname) 
-	Xfree (qd->pathname); /* [RJM 06/97: text filename] */
-      Xfree (qd);
+	delete (qd->pathname); /* [RJM 06/97: text filename] */
+      delete qd;
       break;
     }
@@ -679,5 +679,5 @@
 #if defined(PARADOCNUM) || defined(NZDL)
   if (qd->paragraph != NULL) {
-    Xfree (qd->paragraph);
+    delete (qd->paragraph);
     qd->paragraph = NULL;
   }
@@ -696,10 +696,10 @@
   FreeStemDict (qd->sd);
   close_all_files (qd);
-  Xfree (qd->textpathname); /* [RJM 06/97: text filename] */
-  Xfree (qd->pathname);
+  delete (qd->textpathname); /* [RJM 06/97: text filename] */
+  delete (qd->pathname);
   QueryData_FreeQueryDocs (qd);
   if (qd->TL != NULL) TermList_destroy(&qd->TL);         /* [RJM 07/98: Memory Leak] */
   if (qd->QTL != NULL) QueryTermList_free(&qd->QTL);  /* [RJM 07/98: Memory Leak] */
-  Xfree (qd);
+  delete qd;
 
   /* other global stuff hanging around */
@@ -777,5 +777,5 @@
   if (qd->TextBuffer)
     {
-      Xfree (qd->TextBuffer);
+      delete qd->TextBuffer;
       ChangeMemInUse (qd, -qd->TextBufferLen);
     }
@@ -799,5 +799,5 @@
 	if (qd->DL->DE[i].CompTextBuffer)
 	  {
-	    Xfree (qd->DL->DE[i].CompTextBuffer);
+	    delete qd->DL->DE[i].CompTextBuffer;
 	    qd->DL->DE[i].CompTextBuffer = NULL;
 	    ChangeMemInUse (qd, -qd->DL->DE[i].Len);
@@ -903,5 +903,5 @@
   qd->TextBufferLen = (int) (qd->td->cth.ratio * 1.01 *
 			     DocEntry_length(DE)) + 100;
-  if (!(qd->TextBuffer = (unsigned char *) Xmalloc (qd->TextBufferLen)))
+  if (!(qd->TextBuffer = new unsigned char[qd->TextBufferLen]))
     {
       fprintf (stderr, "No memory for TextBuffer\n");
Index: trunk/gsdl/src/mgpp/text/bool_optimiser.cpp
===================================================================
--- trunk/gsdl/src/mgpp/text/bool_optimiser.cpp	(revision 710)
+++ trunk/gsdl/src/mgpp/text/bool_optimiser.cpp	(revision 711)
@@ -24,4 +24,7 @@
 /*
    $Log$
+   Revision 1.2  1999/10/17 23:43:22  cs025
+   Changes to eradicate Xmalloc
+
    Revision 1.1  1999/10/11 02:57:01  cs025
    Base install of MG-PP
@@ -159,6 +162,6 @@
   BOOL_SIBLING (not_tree) = sibling;
 
-  Xfree (child);
-  Xfree (a);
+  delete (child);
+  delete (a);
 
 }
@@ -436,5 +439,5 @@
 
   bcopy ((void *) child, (void *) tree, sizeof (bool_tree_node));
-  Xfree (child);
+  delete (child);
   BOOL_SIBLING (last) = next;
 
@@ -475,5 +478,5 @@
 	      BOOL_TAG (tree) = N_none;
 	      BOOL_CHILD (tree) = NULL;
-	      Xfree (child);
+	      delete (child);
 	      break;
 	    }
@@ -484,5 +487,5 @@
 	      BOOL_TAG (tree) = N_all;
 	      BOOL_CHILD (tree) = NULL;
-	      Xfree (child);
+	      delete (child);
 	      break;
 	    }
@@ -544,5 +547,5 @@
 	    }
 
-	  Xfree (child);
+	  delete (child);
 	  child = sibling;
 	}
@@ -571,5 +574,5 @@
       bcopy ((void *) child, (void *) and_tree, sizeof (bool_tree_node));
       BOOL_SIBLING (and_tree) = save_sibling;
-      Xfree (child);
+      delete (child);
     }
 
@@ -613,5 +616,5 @@
 	      BOOL_SIBLING (prev) = sibling;
 	    }
-	  Xfree (child);
+	  delete (child);
 	  child = sibling;
 
@@ -641,5 +644,5 @@
       bcopy ((void *) child, (void *) or_tree, sizeof (bool_tree_node));
       BOOL_SIBLING (or_tree) = save_sibling;
-      Xfree (child);
+      delete (child);
     }
 
@@ -726,5 +729,5 @@
 	bool_tree_node *c = BOOL_CHILD (n);
 	next = BOOL_SIBLING (n);
-	Xfree (n);
+	delete (n);
 	if (next)
 	  BOOL_SIBLING (c) = BOOL_CHILD (next);
@@ -885,5 +888,5 @@
     }
 
-  if (!(list = (bool_tree_node **) Xmalloc (sizeof (bool_tree_node *) * count)))
+  if (!(list = new (bool_tree_node *)[count]))
     return;
 
@@ -904,5 +907,5 @@
   BOOL_SIBLING (list[count - 1]) = NULL;
   BOOL_CHILD (and_tree) = list[0];
-  Xfree (list);
+  delete list;
   /* ----------------------------------------------------- */
 
Index: trunk/gsdl/src/mgpp/text/bool_parser.cpp
===================================================================
--- trunk/gsdl/src/mgpp/text/bool_parser.cpp	(revision 710)
+++ trunk/gsdl/src/mgpp/text/bool_parser.cpp	(revision 711)
@@ -231,5 +231,5 @@
 	{
 	  static char word[MAXSTEMLEN + 1]; /* [RJM 07/98: Memory Leak] */
-	  char *sWord = (char *) Xmalloc(MAXSTEMLEN + 1);
+	  char *sWord = new char[MAXSTEMLEN + 1];
 	  int stem_to_apply, method_using = -1;
 
@@ -270,5 +270,5 @@
 	      yylval.text = word;
 	      *ptr = buf_ptr; /* fix up ptr */
-	      Xfree (sWord);
+	      delete sWord;
 	      return TERM;
 	    }
@@ -282,9 +282,9 @@
 		  /* [RPAP - Feb 97: Term Frequency] */ 
 		  int i, freq = 0;
-		  for (i = 0; i < Terms->size(); i++)
+		  for (i = 0; i < Terms->num; i++)
 		    freq += Terms->TE[i].WE.count;
 		  QueryTermList_AddQueryTerm (query_term_list, (unsigned char *) word, freq, method_using);
 
-		  Xfree (sWord);
+		  delete sWord;
 		  mode = 1;
 		  return '(';
@@ -293,5 +293,5 @@
 		{
 		  /* Word does not exists - include in tree anyway */
-		  Xfree (sWord);
+		  delete sWord;
 
 		  /* [RPAP - Feb 97: Term Frequency] */
@@ -339,5 +339,5 @@
   else  /* mode == 2 */
     {
-      if (termnum >= Terms->size())
+      if (termnum >= Terms->num)
 	{
 	  mode = 0;
Index: trunk/gsdl/src/mgpp/text/bool_tester.cpp
===================================================================
--- trunk/gsdl/src/mgpp/text/bool_tester.cpp	(revision 710)
+++ trunk/gsdl/src/mgpp/text/bool_tester.cpp	(revision 711)
@@ -24,4 +24,7 @@
 /*
    $Log$
+   Revision 1.2  1999/10/17 23:43:23  cs025
+   Changes to eradicate Xmalloc
+
    Revision 1.1  1999/10/11 02:57:06  cs025
    Base install of MG-PP
@@ -76,6 +79,6 @@
 #define STEM_METHOD 3
 
-static FILE *file_in = stdin;
-static FILE *file_out = stdout;
+#define FILE_IN stdin
+#define FILE_OUT stdout
 static char line[MAX_LINE_LEN + 1];
 
@@ -147,11 +150,11 @@
       if (res == 0)
 	{
-	  fprintf (file_out, "\n***Parsed Expression***\n");
-	  PrintBoolTree (tree, file_out);
-	  fputc ('\n', file_out);
+	  fprintf (FILE_OUT, "\n***Parsed Expression***\n");
+	  PrintBoolTree (tree, FILE_OUT);
+	  fputc ('\n', FILE_OUT);
 	  OptimiseBoolTree (tree, term_list, opt_type);
-	  fprintf (file_out, "\n***Optimised Expression ***\n");
-	  PrintBoolTree (tree, file_out);
-	  fputc ('\n', file_out);
+	  fprintf (FILE_OUT, "\n***Optimised Expression ***\n");
+	  PrintBoolTree (tree, FILE_OUT);
+	  fputc ('\n', FILE_OUT);
 	}
 
@@ -170,5 +173,5 @@
 prompt (char *str)
 {
-  fprintf (file_out, "\n%s\n", str);
-  return fgets (line, MAX_LINE_LEN, file_in);
+  fprintf (FILE_OUT, "\n%s\n", str);
+  return fgets (line, MAX_LINE_LEN, FILE_IN);
 }
Index: trunk/gsdl/src/mgpp/text/bool_tree.cpp
===================================================================
--- trunk/gsdl/src/mgpp/text/bool_tree.cpp	(revision 710)
+++ trunk/gsdl/src/mgpp/text/bool_tree.cpp	(revision 711)
@@ -41,5 +41,5 @@
 {
   bool_tree_node *n;
-  if (!(n = (bool_tree_node *) Xmalloc (sizeof (bool_tree_node))))
+  if (!(n = new bool_tree_node))
     FatalError (1, "Can not create bool_tree_node for boolean query");
   n->tag = tag;
@@ -125,5 +125,5 @@
 	FreeTree (BOOL_CHILD (tree));
       sibling = BOOL_SIBLING (tree);
-      Xfree (tree);
+      delete (tree);
       tree = sibling;
     }
Index: trunk/gsdl/src/mgpp/text/commands.cpp
===================================================================
--- trunk/gsdl/src/mgpp/text/commands.cpp	(revision 710)
+++ trunk/gsdl/src/mgpp/text/commands.cpp	(revision 711)
@@ -24,4 +24,7 @@
 /*
    $Log$
+   Revision 1.2  1999/10/17 23:43:24  cs025
+   Changes to eradicate Xmalloc
+
    Revision 1.1  1999/10/11 02:57:08  cs025
    Base install of MG-PP
@@ -241,5 +244,5 @@
 
   /* join the two parameters together */
-  buf = (char *) Xmalloc (strlen (param1) + strlen (param2) + 1);
+  buf = new char[strlen (param1) + strlen (param2) + 1];
   strcpy (buf, param1);
   strcat (buf, param2);
@@ -268,5 +271,5 @@
       InPipe = 0;
       InFile = stdin;
-      Xfree (buf);
+      delete buf;
       return;
     }
@@ -303,5 +306,5 @@
       InFile = stdin;
     }
-  Xfree (buf);
+  delete buf;
 }
 
@@ -320,5 +323,5 @@
 
   /* join the two parameters together */
-  buf = (char *) Xmalloc (strlen (param1) + strlen (param2) + 1);
+  buf = new char[strlen (param1) + strlen (param2) + 1];
   strcpy (buf, param1);
   strcat (buf, param2);
@@ -350,5 +353,5 @@
       OutPipe = 0;
       OutFile = stdout;
-      Xfree (buf);
+      delete buf;
       return;
     }
@@ -384,5 +387,5 @@
       OutFile = stdout;
     }
-  Xfree (buf);
+  delete buf;
 }
 
Index: trunk/gsdl/src/mgpp/text/grbIndex.cpp
===================================================================
--- trunk/gsdl/src/mgpp/text/grbIndex.cpp	(revision 710)
+++ trunk/gsdl/src/mgpp/text/grbIndex.cpp	(revision 711)
@@ -24,4 +24,7 @@
 /*
    $Log$
+   Revision 1.4  1999/10/17 23:43:24  cs025
+   Changes to eradicate Xmalloc
+
    Revision 1.3  1999/10/12 04:13:11  cs025
    Changes made to eradicate use of GetEnv elsewhere.
@@ -184,7 +187,7 @@
 	{
 	  if (Stats[i].name)
-	    Xfree (Stats[i].name);
+	    delete Stats[i].name;
 	  if (Stats[i].text)
-	    Xfree (Stats[i].text);
+	    delete Stats[i].text;
 	}
       Xfree (Stats);
@@ -483,5 +486,5 @@
   if (post_proc)
     {
-      Xfree (post_proc);
+      delete post_proc;
       post_proc = NULL;
     }
@@ -940,7 +943,7 @@
   if (OutputType == OUTPUT_TEXT || OutputType == OUTPUT_HILITE)
     {
-      Xfree (doc_sepstr);
-      Xfree (para_sepstr);
-      Xfree (para_start);
+      delete doc_sepstr;
+      delete para_sepstr;
+      delete para_start;
     }
 
@@ -955,5 +958,5 @@
   de_escape_string (terminator);
   fputs (terminator, out);
-  Xfree (terminator);
+  delete terminator;
 }
 
Index: trunk/gsdl/src/mgpp/text/mg_invf_rebuild.cpp
===================================================================
--- trunk/gsdl/src/mgpp/text/mg_invf_rebuild.cpp	(revision 710)
+++ trunk/gsdl/src/mgpp/text/mg_invf_rebuild.cpp	(revision 711)
@@ -50,4 +50,7 @@
 /*
    $Log$
+   Revision 1.2  1999/10/17 23:43:26  cs025
+   Changes to eradicate Xmalloc
+
    Revision 1.1  1999/10/11 02:57:58  cs025
    Base install of MG-PP
@@ -355,5 +358,5 @@
   for (i = 0; i < ifh_in.no_of_words; i++)
     {
-      unsigned long blk, p;
+      unsigned long blk, docCount;
       unsigned long odn_blk = 0, olen_blk = 0;
       unsigned long idn_blk = 0, ilen_blk = 0;
@@ -374,6 +377,6 @@
       NTOHUL(bytes_out);  /* [RPAP - Jan 97: Endian Ordering] */
 
-      p = word.documents();
-      blk = BIO_Bblock_Init (idh.static_num_of_docs, p);
+      docCount = word.documents();
+      blk = BIO_Bblock_Init (idh.static_num_of_docs, docCount);
       switch (outmode)
 	{
@@ -381,14 +384,14 @@
 	  {
 	    unsigned long len;
-	    if (p <= ifh_out.params[0])
+	    if (docCount <= ifh_out.params[0])
 	      out_k = 0;
 	    else
 	      {
 		out_k = ifh_out.params[0];
-		len = BIO_Bblock_Bound (N, p);
+		len = BIO_Bblock_Bound (N, docCount);
 		if (ifh_in.InvfLevel >= 2)
 		  len += word.words();
-		odn_blk = BIO_Bblock_Init (idh.num_of_docs, (p + out_k - 1) / out_k);
-		olen_blk = BIO_Bblock_Init (len, (p + out_k - 1) / out_k);
+		odn_blk = BIO_Bblock_Init (idh.num_of_docs, (docCount + out_k - 1) / out_k);
+		olen_blk = BIO_Bblock_Init (len, (docCount + out_k - 1) / out_k);
 	      }
 	    break;
@@ -397,17 +400,17 @@
 	  {
 	    unsigned long len;
-	    if (p <= mins)
+	    if (docCount <= mins)
 	      out_k = 0;
 	    else
 	      {
-		out_k = (int) (2 * sqrt ((double) p / max_nodes));
+		out_k = (int) (2 * sqrt ((double) docCount / max_nodes));
 		if (out_k <= mins)
 		  out_k = mins;
-		len = BIO_Bblock_Bound (N, p);
+		len = BIO_Bblock_Bound (N, docCount);
 		if (ifh_in.InvfLevel >= 2)
 		  len += word.words();
 		odn_blk = BIO_Bblock_Init (idh.num_of_docs,
-					   (p + out_k - 1) / out_k);
-		olen_blk = BIO_Bblock_Init (len, (p + out_k - 1) / out_k);
+					   (docCount + out_k - 1) / out_k);
+		olen_blk = BIO_Bblock_Init (len, (docCount + out_k - 1) / out_k);
 	      }
 	    break;
@@ -422,14 +425,14 @@
 	  {
 	    unsigned long len;
-	    if (p <= ifh_in.params[0])
+	    if (docCount <= ifh_in.params[0])
 	      in_k = 0;
 	    else
 	      {
 		in_k = ifh_in.params[0];
-		len = BIO_Bblock_Bound (N, p);
+		len = BIO_Bblock_Bound (N, docCount);
 		if (ifh_in.InvfLevel >= 2)
 		  len += word.words();
-		idn_blk = BIO_Bblock_Init (idh.num_of_docs, (p + in_k - 1) / in_k);
-		ilen_blk = BIO_Bblock_Init (len, (p + in_k - 1) / in_k);
+		idn_blk = BIO_Bblock_Init (idh.num_of_docs, (docCount + in_k - 1) / in_k);
+		ilen_blk = BIO_Bblock_Init (len, (docCount + in_k - 1) / in_k);
 	      }
 	    break;
@@ -438,5 +441,5 @@
 	  {
 	    unsigned long len;
-	    if (p <= ifh_in.params[1])
+	    if (docCount <= ifh_in.params[1])
 	      {
 		in_k = 0;
@@ -444,13 +447,13 @@
 	    else
 	      {
-		in_k = (int) (2 * sqrt ((double) p / ifh_in.params[0]));
+		in_k = (int) (2 * sqrt ((double) docCount / ifh_in.params[0]));
 		if (in_k <= ifh_in.params[1])
 		  in_k = ifh_in.params[1];
-		len = BIO_Bblock_Bound (N, p);
+		len = BIO_Bblock_Bound (N, docCount);
 		if (ifh_in.InvfLevel >= 2)
 		  len += word.words();
 		idn_blk = BIO_Bblock_Init (idh.num_of_docs,
-					   (p + in_k - 1) / in_k);
-		ilen_blk = BIO_Bblock_Init (len, (p + in_k - 1) / in_k);
+					   (docCount + in_k - 1) / in_k);
+		ilen_blk = BIO_Bblock_Init (len, (docCount + in_k - 1) / in_k);
 	      }
 	    break;
@@ -460,5 +463,5 @@
 	}
 
-      if (!(ii = (invf_info *) Xmalloc (sizeof (invf_info) * p)))
+      if (!(ii = (invf_info *) Xmalloc (sizeof (invf_info) * docCount)))
 	FatalError (1, "Unable to allocate memory for \"ii\"\n");
 
@@ -467,10 +470,10 @@
       kd = 0;
       DECODE_CONTINUE (in_buf)
-	for (j = 0; j < p; j++, kd++)
+	for (j = 0; j < docCount; j++, kd++)
 	{
 	  unsigned long doc_diff, count = 0;
 	  if (kd == in_k)
 	    kd = 0;
-	  if (in_k && kd == 0 && j + in_k < p)
+	  if (in_k && kd == 0 && j + in_k < docCount)
 	    {
 	      int temp;
@@ -480,5 +483,5 @@
 	    }
 	  ii[j].bits_so_far = bits_so_far;
-	  if (in_k && kd == in_k - 1 && j != p - 1)
+	  if (in_k && kd == in_k - 1 && j != docCount - 1)
 	    {
 	      int count;
@@ -517,5 +520,5 @@
       kd = 0;
       ENCODE_CONTINUE (out_buf)
-	for (j = 0; j < p; j++, kd++)
+	for (j = 0; j < docCount; j++, kd++)
 	{
 	  if (kd == out_k)
@@ -523,5 +526,5 @@
 	  if (out_k && kd == 0)
 	    {
-	      if (j + out_k < p)
+	      if (j + out_k < docCount)
 		{
 		  int num = ii[j + out_k - 1].doc_num - last_major;
@@ -535,5 +538,5 @@
 		}
 	    }
-	  if (!(out_k && kd == out_k - 1 && j != p - 1))
+	  if (!(out_k && kd == out_k - 1 && j != docCount - 1))
 	    buffer.bblock_encode (ii[j].doc_num - doc_num, blk, &bits_out);
 	  doc_num = ii[j].doc_num;
Index: trunk/gsdl/src/mgpp/text/mgdictlist.cpp
===================================================================
--- trunk/gsdl/src/mgpp/text/mgdictlist.cpp	(revision 710)
+++ trunk/gsdl/src/mgpp/text/mgdictlist.cpp	(revision 711)
@@ -37,4 +37,7 @@
 /*
    $Log$
+   Revision 1.2  1999/10/17 23:43:27  cs025
+   Changes to eradicate Xmalloc
+
    Revision 1.1  1999/10/11 02:58:08  cs025
    Base install of MG-PP
@@ -195,6 +198,6 @@
 	      cfh.hd.maxcodelen, code, word2str (prev));
     }
-  Xfree (codes);
-  Xfree (cfh.hd.clens);
+  delete codes;
+  delete cfh.hd.clens;
 }
 
@@ -232,6 +235,6 @@
 	  }
       }
-  Xfree (codes);
-  Xfree (hd.clens);
+  delete codes;
+  delete hd.clens;
 }
 
Index: trunk/gsdl/src/mgpp/text/mgquery.cpp
===================================================================
--- trunk/gsdl/src/mgpp/text/mgquery.cpp	(revision 710)
+++ trunk/gsdl/src/mgpp/text/mgquery.cpp	(revision 711)
@@ -24,4 +24,7 @@
 /*
    $Log$
+   Revision 1.4  1999/10/17 23:43:28  cs025
+   Changes to eradicate Xmalloc
+
    Revision 1.3  1999/10/12 04:12:46  cs025
    Changes made to assist with eradication of GetEnv elsewhere in the
@@ -187,7 +190,7 @@
 	{
 	  if (Stats[i].name)
-	    Xfree (Stats[i].name);
+	    delete Stats[i].name;
 	  if (Stats[i].text)
-	    Xfree (Stats[i].text);
+	    delete Stats[i].text;
 	}
       Xfree (Stats);
@@ -486,5 +489,5 @@
   if (post_proc)
     {
-      Xfree (post_proc);
+      delete post_proc;
       post_proc = NULL;
     }
@@ -965,7 +968,7 @@
   if (OutputType == OUTPUT_TEXT || OutputType == OUTPUT_HILITE)
     {
-      Xfree (doc_sepstr);
-      Xfree (para_sepstr);
-      Xfree (para_start);
+      delete doc_sepstr;
+      delete para_sepstr;
+      delete para_start;
     }
 
@@ -980,5 +983,5 @@
   de_escape_string (terminator);
   fputs (terminator, out);
-  Xfree (terminator);
+  delete terminator;
 }
 
Index: trunk/gsdl/src/mgpp/text/query.ranked.cpp
===================================================================
--- trunk/gsdl/src/mgpp/text/query.ranked.cpp	(revision 710)
+++ trunk/gsdl/src/mgpp/text/query.ranked.cpp	(revision 711)
@@ -51,4 +51,7 @@
 /*
    $Log$
+   Revision 1.3  1999/10/17 23:43:29  cs025
+   Changes to eradicate Xmalloc
+
    Revision 1.2  1999/10/12 04:13:52  cs025
    Calls to GetEnv eradicated; interface to parsing of query text
@@ -128,5 +131,16 @@
     int MaxSize;
     HeapComp HC;
-    HeapEntry HE[1];
+    HeapEntry *HE;
+
+    Heap(int size)
+    {
+      HE = new HeapEntry[size];
+    }
+
+    ~Heap()
+    {
+      if (HE != NULL)
+	delete HE;
+    }
   }
 Heap;
@@ -137,5 +151,5 @@
 {
   Heap *H;
-  H = (Heap *) Xmalloc (sizeof (Heap) + (size - 1) * sizeof (HeapEntry));
+  H = new Heap(size);
   if (!H)
     return NULL;
@@ -644,6 +658,4 @@
      document weights which we retrieve from the ".idx.wgt" file and put
      the resulting data into a heap */
-
-
   he = H->HE;
   H->NumItems = MaxDocs;
@@ -805,5 +817,4 @@
     }
 
-
   if (rqi->Exact && qd->id->ifh.InvfLevel != 3)
     {
@@ -957,6 +968,4 @@
 	}
     }
-
-
 
   H->HC = Heap_Greater;
@@ -1062,5 +1071,5 @@
     LT_free (qd, LT);
 
-  if (H) Xfree (H); /* [RJM 07/98: Memory Leak] */
+  if (H) delete H; /* [RJM 07/98: Memory Leak] */
 
   return (Docs);
Index: trunk/gsdl/src/mgpp/text/read_line.cpp
===================================================================
--- trunk/gsdl/src/mgpp/text/read_line.cpp	(revision 710)
+++ trunk/gsdl/src/mgpp/text/read_line.cpp	(revision 711)
@@ -83,9 +83,8 @@
 static void memory_error_and_abort ();
 
-char *
-xmalloc (bytes)
-     int bytes;
-{
-  char *temp = (char *) Xmalloc (bytes);
+void *
+xmalloc (size_t bytes)
+{
+  void *temp = Xmalloc (bytes);
 
   if (!temp)
@@ -94,15 +93,13 @@
 }
 
-char *
-xrealloc (pointer, bytes)
-     char *pointer;
-     int bytes;
-{
-  char *temp;
+void *
+xrealloc (void *pointer, size_t bytes)
+{
+  void *temp;
 
   if (!pointer)
-    temp = (char *) xmalloc (bytes);
+    temp = xmalloc (bytes);
   else
-    temp = (char *) Xrealloc (pointer, bytes);
+    temp = Xrealloc (pointer, bytes);
 
   if (!temp)
@@ -150,5 +147,5 @@
   static char *the_line = NULL;
   if (the_line)
-    Xfree (the_line);
+    delete the_line;
   the_line = NULL;
   rl_instream = InFile;
@@ -194,6 +191,7 @@
   char *s;
   if (line)
-    Xfree (line);
+    delete line;
   line = NULL;
+
   if (!(s = GetLine ("> ")))
     return (NULL);
@@ -210,5 +208,5 @@
       if (!(s = GetLine ("? ")))
 	return (NULL);
-      if (!(newline = (char *) Xmalloc (strlen (line) + strlen (s) + 2)))
+      if (!(newline = new char[strlen (line) + strlen (s) + 2]))
 	{
 	  fprintf (stderr, "Unable to allocate memory for the line\n");
@@ -218,5 +216,5 @@
       strcat (newline, "\n");
       strcat (newline, s);
-      Xfree (line);
+      delete line;
       line = newline;
     }
Index: trunk/gsdl/src/mgpp/text/stem_search.cpp
===================================================================
--- trunk/gsdl/src/mgpp/text/stem_search.cpp	(revision 710)
+++ trunk/gsdl/src/mgpp/text/stem_search.cpp	(revision 711)
@@ -48,4 +48,7 @@
 /*
    $Log$
+   Revision 1.2  1999/10/17 23:43:29  cs025
+   Changes to eradicate Xmalloc
+
    Revision 1.1  1999/10/11 02:58:32  cs025
    Base install of MG-PP
@@ -108,69 +111,4 @@
       return (NULL);
     }
-  /*
-  si->stem_idx_file = stem_idx_file;
-  si->MemForStemIdx = 0;
-
-  Fread (&si->sih, sizeof (si->sih), 1, stem_idx_file);
-  // [RPAP - Jan 97: Endian Ordering]
-  NTOHUL(si->sih.lookback);
-  NTOHUL(si->sih.block_size);
-  NTOHUL(si->sih.num_blocks);
-  NTOHUL(si->sih.blocks_start);
-  NTOHUL(si->sih.index_chars);
-  NTOHUL(si->sih.num_of_words);
-
-  if (!(buffer = (u_char *) Xmalloc (si->sih.index_chars)))
-    {
-      Xfree (si);
-      mg_errno = MG_NOMEM;
-      return (NULL);
-    };
-  si->MemForStemIdx += si->sih.index_chars;
-
-  if (!(si->index = (u_char **) Xmalloc (si->sih.num_blocks * sizeof (*si->index))))
-    {
-      Xfree (si);
-      Xfree (buffer);
-      mg_errno = MG_NOMEM;
-      return (NULL);
-    };
-  si->MemForStemIdx += si->sih.num_blocks * sizeof (*si->index);
-
-  if (!(si->pos = (long unsigned int *) Xmalloc (si->sih.num_blocks * sizeof (*si->pos))))
-    {
-      Xfree (si->index);
-      Xfree (si);
-      Xfree (buffer);
-      mg_errno = MG_NOMEM;
-      return (NULL);
-    };
-  si->MemForStemIdx += si->sih.num_blocks * sizeof (*si->pos);
-
-  if (!(si->buffer = (u_char *) Xmalloc (si->sih.block_size * sizeof (*si->buffer))))
-    {
-      Xfree (buffer);
-      Xfree (si->index);
-      Xfree (si->buffer);
-      Xfree (si);
-      mg_errno = MG_NOMEM;
-      return (NULL);
-    };
-  si->MemForStemIdx += si->sih.block_size * sizeof (*si->buffer);
-
-  si->active = -1;
-
-  for (i = 0; i < si->sih.num_blocks; i++)
-    {
-      register u_char len;
-      si->index[i] = buffer;
-      len = Getc (stem_idx_file);
-      *buffer++ = len;
-      Fread (buffer, sizeof (u_char), len, stem_idx_file);
-      buffer += len;
-      Fread (&si->pos[i], sizeof (*si->pos), 1, stem_idx_file);
-      NTOHUL(si->pos[i]);  // [RPAP - Jan 97: Endian Ordering]
-    }
-  */
   mg_errno = MG_NOERROR;
 
@@ -300,22 +238,4 @@
       StemBlock_read(sd, block, &first_word, &last_invf_len, &num_words, 
 		     &index, &num_indexes);
-      /*      int i;
-
-      Fseek (sd->stem_file, sd->pos[block] + sd->sdh.blocks_start, 0);
-      Fread (sd->buffer, sd->sdh.block_size, sizeof (u_char), sd->stem_file);
-      sd->active = sd->pos[block];
-
-      // [RPAP - Jan 97: Endian Ordering] 
-      first_word = (unsigned long *) (sd->buffer);
-      NTOHUL(*first_word);
-      last_invf_len = (unsigned long *) (first_word + 1);
-      NTOHUL(*last_invf_len);
-      num_words = (unsigned short *) (last_invf_len + 1);
-      NTOHUS(*num_words);
-      index = num_words + 1;
-      num_indexes = ((*num_words - 1) / sd->sdh.lookback) + 1;
-
-      for (i = 0; i < num_indexes; i++)
-      NTOHUS(index[i]);*/
     }
   else
@@ -334,24 +254,4 @@
   */
   hi = Word_BaseIndexNo(num_indexes, base, index, Word);
-  /*
-  lo = 0;
-  hi = num_indexes - 1;
-  while (lo <= hi)
-    {
-      mid = (lo + hi) / 2;
-      c = casecompare (Word, base + index[mid] + 1);  // [RPAP - Jan 97: Stem Index Change]
-      if (c < 0)
-	hi = mid - 1;
-      else if (c > 0)
-	lo = mid + 1;
-      else
-	{
-	  hi = mid;
-	  break;
-	}
-    }
-  if (hi < 0)
-    hi = 0;
-  */
 
   res = hi * sd->sdh.lookback;
@@ -365,16 +265,6 @@
   while (res < *num_words)
     {
-      //unsigned copy, suff;
       unsigned long invfp;
-      /*      if (res >= *num_words)
-	      return (-1);*/
       StemBlock_ReadWordString(&base, prev);
-      /*      
-      copy = *base++;
-      suff = *base++;
-      bcopy ((void *) base, (void *) (prev + copy + 1), suff);
-      base += suff;
-      *prev = copy + suff;
-      */
 
       c = casecompare (Word, prev);   /* [RPAP - Jan 97: Stem Index Change] */
@@ -407,5 +297,4 @@
 	{
 	  /* Calculate invf_len is necessary */
-	  // unsigned long next_invfp;
 	  if (!invf_len)
 	    return (*first_word + res);
@@ -421,12 +310,4 @@
 	  /* Skip over most of the next word to get to the invf_ptr */
 	  *invf_len = Word_SkipToNextInvfPtr(&base, invfp);
-	  /*
-	  base++;
-	  suff = *base++;
-	  base += suff + sizeof (unsigned long) * 2;
-	  bcopy ((void *) base, (void *) &next_invfp, sizeof (next_invfp));
-	  NTOHUL(next_invfp);  // [RPAP - Jan 97: Endian Ordering] 
-	  *invf_len = next_invfp - invfp;
-	  */
 	  return (*first_word + res);
 	}
@@ -507,20 +388,4 @@
       StemIdx_block_readNext((void *) si->stem_idx_file, si, idx_block, &idx_first_word, &idx_num_words,
 			     &idx_index, &idx_num_indexes, stemAbstractSeeker, stemAbstractReader);
-      /*
-      Fseek (si->stem_idx_file, si->pos[idx_block] + si->sih.blocks_start, 0);
-      Fread (si->buffer, si->sih.block_size, sizeof (u_char), si->stem_idx_file);
-      si->active = si->pos[idx_block];
-
-      idx_first_word = (unsigned long *) (si->buffer);
-      NTOHUL(*idx_first_word);  // [RPAP - Jan 97: Endian Ordering]
-      idx_num_words = (unsigned short *) (idx_first_word + 1);
-      NTOHUS(*idx_num_words);  // [RPAP - Jan 97: Endian Ordering]
-      idx_index = idx_num_words + 1;
-      idx_num_indexes = ((*idx_num_words - 1) / si->sih.lookback) + 1;
-
-      // [RPAP - Jan 97: Endian Ordering]
-      for (j = 0; j < idx_num_indexes; j++)
-	NTOHUS(idx_index[j]);
-      */
     }
   else
@@ -542,24 +407,4 @@
 
     hi = Word_BaseIndexNo(idx_num_indexes, idx_base, idx_index, sWord);
-    /*
-    lo = 0;
-    hi = idx_num_indexes - 1;
-    while (lo <= hi)
-      {
-	mid = (lo + hi) / 2;
-	c = casecompare (sWord, idx_base + idx_index[mid] + 1);
-	if (c < 0)
-	  hi = mid - 1;
-	else if (c > 0)
-	  lo = mid + 1;
-	else
-	  {
-	    hi = mid;
-	    break;
-	  }
-      }
-    if (hi < 0)
-      hi = 0;
-    */
     idx_res = hi * si->sih.lookback;
     idx_base += idx_index[hi];
@@ -573,12 +418,4 @@
 	return (-1);
       StemIdx_ReadWordString(&idx_base, idx_prev);
-
-      /*
-      copy = *idx_base++;
-      suff = *idx_base++;
-      bcopy ((void *) idx_base, (void *) (idx_prev + copy + 1), suff);
-      idx_base += suff;
-      *idx_prev = copy + suff;
-      */
 
       c = casecompare (sWord, idx_prev);
@@ -608,18 +445,4 @@
        */
       StemIdx_ReadPosEntry(&idx_base, &num_cases, (unsigned int *) &block, &blk_index, &offset);
-      /*
-      bcopy ((void *) idx_base, (void *) &num_cases, sizeof (num_cases));
-      NTOHUI(num_cases);  // [RPAP - Jan 97: Endian Ordering]
-      idx_base += sizeof (num_cases);
-      bcopy ((void *) idx_base, (void *) &block, sizeof (block));
-      NTOHUI(block);  // [RPAP - Jan 97: Endian Ordering]
-      idx_base += sizeof (block);
-      bcopy ((void *) idx_base, (void *) &blk_index, sizeof (blk_index));
-      NTOHUS(blk_index);  // [RPAP - Jan 97: Endian Ordering] 
-      idx_base += sizeof (blk_index);
-      bcopy ((void *) idx_base, (void *) &offset, sizeof (offset));
-      NTOHUS(offset);  // [RPAP - Jan 97: Endian Ordering]
-      idx_base += sizeof (offset);
-      */
       
 
@@ -636,22 +459,4 @@
 	  StemBlock_read(sd, block, &first_word, &last_invf_len, &num_words,
 			 &index, &num_indexes);
-	  /*
-	  Fseek (sd->stem_file, sd->pos[block] + sd->sdh.blocks_start, 0);
-	  Fread (sd->buffer, sd->sdh.block_size, sizeof (u_char), sd->stem_file);
-	  sd->active = sd->pos[block];
-
-	  first_word = (unsigned long *) (sd->buffer);
-	  NTOHUL(*first_word);  // [RPAP - Jan 97: Endian Ordering] 
-	  last_invf_len = (unsigned long *) (first_word + 1);
-	  NTOHUL(*last_invf_len);  // [RPAP - Jan 97: Endian Ordering] 
-	  num_words = (unsigned short *) (last_invf_len + 1);
-	  NTOHUS(*num_words);  // [RPAP - Jan 97: Endian Ordering]
-	  index = num_words + 1;
-	  num_indexes = ((*num_words - 1) / sd->sdh.lookback) + 1;
-
-	  // [RPAP - Jan 97: Endian Ordering] 
-	  for (j = 0; j < num_indexes; j++)
-	    NTOHUS(index[j]);
-	  */
 	}
       else
@@ -676,11 +481,4 @@
 	  StemBlock_ReadWordString(&base, prev);
 	  
-	  /*
-	  copy = *base++;
-	  suff = *base++;
-	  bcopy ((void *) base, (void *) (prev + copy + 1), suff);
-	  base += suff;
-	  *prev = copy + suff;
-	  */
 	  base += sizeof (unsigned long);   /* skip doc_count */
 	  base += sizeof (unsigned long);   /* skip count */
@@ -699,11 +497,4 @@
 	    return (-1);
 	  StemBlock_ReadWordString(&base, prev);
-	  /*
-	  copy = *base++;
-	  suff = *base++;
-	  bcopy ((void *) base, (void *) (prev + copy + 1), suff);
-	  base += suff;
-	  *prev = copy + suff;
-	  */
 	      
 	  te.Word = copy_string (prev);
@@ -737,17 +528,8 @@
 	  else
 	    {
-	      //unsigned long next_invfp;
 	      u_char *oldbase = base;
 		  
 	      /* Skip over most of the next word to get to the invf_ptr */
 	      te.WE.invf_len = Word_SkipToNextInvfPtr(&base, invfp);
-	      /*
-	      base++;
-	      suff = *base++;
-	      base += suff + sizeof (unsigned long) * 2;
-	      bcopy ((void *) base, (void *) &next_invfp, sizeof (next_invfp));
-	      NTOHUL(next_invfp);  // [RPAP - Jan 97: Endian Ordering]
-	      te.WE.invf_len = next_invfp - invfp;
-	      */
 	      base = oldbase;
 	    }
@@ -764,27 +546,8 @@
 	  if (res == *num_words - 1 && j + 1 < num_cases)
 	    {
-	      //int ii;
 	      /* Read in next block */
 	      block++;
 	      StemBlock_read(sd, block, &first_word, &last_invf_len, &num_words, 
 			     &index, &num_indexes);
-	      /*
-	      Fseek (sd->stem_file, sd->pos[block] + sd->sdh.blocks_start, 0);
-	      Fread (sd->buffer, sd->sdh.block_size, sizeof (u_char), sd->stem_file);
-	      sd->active = sd->pos[block];
-
-	      first_word = (unsigned long *) (sd->buffer);
-	      NTOHUL(*first_word);  // [RPAP - Jan 97: Endian Ordering] 
-	      last_invf_len = (unsigned long *) (first_word + 1);
-	      NTOHUL(*last_invf_len);  // [RPAP - Jan 97: Endian Ordering] 
-	      num_words = (unsigned short *) (last_invf_len + 1);
-	      NTOHUS(*num_words);  // [RPAP - Jan 97: Endian Ordering]
-	      index = num_words + 1;
-	      num_indexes = ((*num_words - 1) / sd->sdh.lookback) + 1;
-
-	      // [RPAP - Jan 97: Endian Ordering]
-	      for (ii = 0; ii < num_indexes; ii++)
-		NTOHUS(index[ii]);
-	      */
 	      base = (u_char *) (index + num_indexes);
 	      base += index[0];
@@ -811,9 +574,9 @@
     FreeStemIdx (sd->stem3);
 
-  Xfree (sd->index[0]);
-  Xfree (sd->index);
-  Xfree (sd->buffer);
-  Xfree (sd->pos);
-  Xfree (sd);
+  delete (sd->index[0]);
+  delete (sd->index);
+  delete (sd->buffer);
+  delete (sd->pos);
+  delete sd;
 }
 
@@ -822,8 +585,8 @@
 FreeStemIdx (stemmed_idx * si)
 {
-  Xfree (si->index[0]);
-  Xfree (si->index);
-  Xfree (si->buffer);
-  Xfree (si->pos);
-  Xfree (si);
-}
+  delete si->index[0];
+  delete si->index;
+  delete si->buffer;
+  delete si->pos;
+  delete si;
+}
Index: trunk/gsdl/src/mgpp/text/text_get.cpp
===================================================================
--- trunk/gsdl/src/mgpp/text/text_get.cpp	(revision 710)
+++ trunk/gsdl/src/mgpp/text/text_get.cpp	(revision 711)
@@ -51,4 +51,7 @@
 /*
    $Log$
+   Revision 1.2  1999/10/17 23:43:30  cs025
+   Changes to eradicate Xmalloc
+
    Revision 1.1  1999/10/11 02:58:39  cs025
    Base install of MG-PP
@@ -68,4 +71,6 @@
    *
  */
+
+typedef enum huff_type {lengths, chars};
 
 static char *RCSID = "$Id$";
@@ -113,8 +118,9 @@
   if (!td->idx_data)
     {
-      td->idx_data = (__idx_data *) Xmalloc (sizeof (*(td->idx_data)) * MG_PAGE_SIZE);
+      td->idx_data = new index_data[MG_PAGE_SIZE];
       if (!td->idx_data)
 	FatalError (1, "Out of memory in FDSL2");
     }
+
   if (td->current_pos == -1 || DN >= td->current_pos + MG_PAGE_SIZE - 1 ||
       DN < td->current_pos)
@@ -125,6 +131,8 @@
       if (rn < 1)
 	rn = 1;
+
       Fseek (td->TextIdxWgtFile, (sizeof (unsigned long) + sizeof (float)) *
 	       (rn - 1) + sizeof (unsigned long), 0);
+
       num = Fread ((char *) td->idx_data, sizeof (*(td->idx_data)), MG_PAGE_SIZE, /* [RPAP - Jan 97: Endian Ordering] */
 		   td->TextIdxWgtFile);
@@ -219,5 +227,5 @@
     DocEnt->FetchStart(qd);
   //    FetchDocStart (qd, DocEnt->DocNum, &DocEnt->SeekPos, &DocEnt->Len);
-  if (!(*DocBuff = (char *) Xmalloc (DocEnt->Len)))
+  if (!(*DocBuff = new char[DocEnt->Len]))
     return (-1);
 
@@ -240,5 +248,5 @@
   text_data *td;
 
-  if (!(td = (text_data *) Xmalloc (sizeof (text_data))))
+  if (!(td = new text_data))
     {
       mg_errno = MG_NOMEM;
@@ -270,6 +278,6 @@
     {
       if (td->idx_data)
-	Xfree (td->idx_data);
-      Xfree (td);
+	delete td->idx_data;
+      delete td;
     }
 }
@@ -292,5 +300,5 @@
   DocEntry **pts;
   int i, j;
-  if (!(pts = (DocEntry **) Xmalloc (num * sizeof (DocEntry *))))
+  if (!(pts = new (DocEntry *)[num]))
     {
       mg_errno = MG_NOMEM;
@@ -309,5 +317,5 @@
     }
 
-  Xfree (pts);
+  delete pts;
   return (0);
 }
@@ -326,5 +334,5 @@
   if (!num)
     return (0);
-  if (!(pts = (DocEntry **) Xmalloc (num * sizeof (DocEntry *))))
+  if (!(pts = new (DocEntry *)[num]))
     {
       mg_errno = MG_NOMEM;
@@ -350,5 +358,5 @@
     }
 
-  Xfree (pts);
+  delete pts;
 
   return (i);
@@ -369,5 +377,5 @@
     if (Docs->CompTextBuffer)
       {
-	Xfree (Docs->CompTextBuffer);
+	delete Docs->CompTextBuffer;
 	Docs->CompTextBuffer = NULL;
 	ChangeMemInUse (qd, -Docs->Len);
@@ -386,12 +394,12 @@
     return;
   if (ad->word_data[0])
-    Xfree (ad->word_data[0]);
+    delete ad->word_data[0];
   if (ad->word_data[1])
-    Xfree (ad->word_data[1]);
+    delete ad->word_data[1];
   if (ad->words[0])
-    Xfree (ad->words[0]);
+    delete ad->words[0];
   if (ad->words[1])
-    Xfree (ad->words[1]);
-  Xfree (ad);
+    delete ad->words[1];
+  delete ad;
 }
 
@@ -402,5 +410,5 @@
   int i;
 
-  if (!(ad = (auxiliary_dict *) Xmalloc (sizeof (auxiliary_dict))))
+  if (!(ad = new auxiliary_dict))
     {
       mg_errno = MG_NOMEM;
@@ -421,5 +429,5 @@
       NTOHUL(ad->afh[i].mem_for_frags);
 
-      if (!(ad->word_data[i] = (u_char *) Xmalloc (ad->afh[i].mem_for_frags)))
+      if (!(ad->word_data[i] = new u_char[ad->afh[i].mem_for_frags]))
 	{
 	  mg_errno = MG_NOMEM;
@@ -427,5 +435,5 @@
 	  return (NULL);
 	}
-      if (!(ad->words[i] = (u_char **) Xmalloc (ad->afh[i].num_frags * sizeof (u_char *))))
+      if (!(ad->words[i] = new (u_char *)[ad->afh[i].num_frags]))
 	{
 	  mg_errno = MG_NOMEM;
@@ -489,11 +497,12 @@
     }
 
-  if (!(vals = (u_char **) Xmalloc (ptrs_reqd * sizeof (*vals))))
+  if (!(vals = new (u_char *)[ptrs_reqd]))
     return (NULL);
 
-  if (!(values = (u_char ***) Xmalloc ((MAX_HUFFCODE_LEN + 1) * sizeof (u_char **))))
+  if (!(values = new (u_char **)[MAX_HUFFCODE_LEN + 1]))
     return (NULL);
 
-  if (!(next_word[0] = (u_char *) Xmalloc (mem_reqd))) return (NULL);
+  if (!(next_word[0] = new u_char[mem_reqd])) 
+    return (NULL);
 
   cd->MemForCompDict += ptrs_reqd * sizeof (*vals) +
@@ -546,15 +555,16 @@
     }
   if (cfh->hd.clens)
-    Xfree (cfh->hd.clens);
+    delete cfh->hd.clens;
   cfh->hd.clens = NULL;
   return values;
 }
 
-int Load_Comp_HuffData(compression_dict *cd, int which, File *dict)
+int Load_Comp_HuffData(compression_dict *cd, int which, File *dict, 
+		       huff_type type)
 {
   huff_data * hd;
   u_long **   vals;
 
-  if (!(hd = (huff_data *) Xmalloc (sizeof (huff_data))))
+  if (!(hd = new huff_data))
     return 1;
   cd->MemForCompDict += sizeof (huff_data);
@@ -564,8 +574,16 @@
     return 3;
   if (hd->clens)
-    Xfree (hd->clens);
+    delete hd->clens;
   hd->clens = NULL;
-  cd->chars_huff[which] = hd;
-  cd->chars_vals[which] = vals;
+  if (type == chars)
+    {
+      cd->chars_huff[which] = hd;
+      cd->chars_vals[which] = vals;
+    }
+  else
+    {
+      cd->lens_huff[which] = hd;
+      cd->lens_vals[which] = vals;
+    }
 
   return 0;
@@ -574,5 +592,5 @@
 int Load_Comp_FragsHeader(compression_dict *cd, int which, int getEscape, File *dict)
 { 
-  if (!(cd->cfh[which] = (comp_frags_header *) Xmalloc (sizeof (*cd->cfh[which]))))
+  if (!(cd->cfh[which] = new comp_frags_header))
     return 1;
   cd->MemForCompDict += sizeof (*cd->cfh[which]);
@@ -592,5 +610,5 @@
   compression_dict *cd;
 
-  if (!(cd = (compression_dict *) Xmalloc (sizeof (compression_dict))))
+  if (!(cd = new compression_dict))
     {
       mg_errno = MG_NOMEM;
@@ -647,5 +665,5 @@
 	      */
 	    }
-	  if (Load_Comp_HuffData(cd, which, dict) != 0)
+	  if (Load_Comp_HuffData(cd, which, dict, chars) != 0)
 	    return NULL;
 	  /*
@@ -663,5 +681,5 @@
 	  cd->chars_vals[which] = vals;
 	  */
-	  if (Load_Comp_HuffData(cd, which, dict) != 0)
+	  if (Load_Comp_HuffData(cd, which, dict, lengths) != 0)
 	    return NULL;
 	  /*
@@ -704,10 +722,9 @@
 	    {
 	    case MG_NOVEL_HUFFMAN_CHARS:
-	      if (Load_Comp_HuffData(cd, which, dict) != 0)
+	      if (Load_Comp_HuffData(cd, which, dict, chars) != 0)
 		return NULL;
 	      /*
 	      if (!(hd = (huff_data *) Xmalloc (sizeof (huff_data))))
 		return NULL;
-	      cd->chars_huff[which] = hd;
 	      cd->MemForCompDict += sizeof (huff_data);
 	      if (F_Read_Huffman_Data (dict, hd, &cd->MemForCompDict,
@@ -716,4 +733,5 @@
 	      if (!(vals = Generate_Huffman_Vals (hd, &cd->MemForCompDict)))
 		return NULL;
+	      cd->chars_huff[which] = hd;
 	      cd->chars_vals[which] = vals;
 	      if (hd->clens)
@@ -722,5 +740,5 @@
 	      */
 
-	      if (Load_Comp_HuffData(cd, which, dict) != 0)
+	      if (Load_Comp_HuffData(cd, which, dict, lengths) != 0)
 		return NULL;
 	      /*
@@ -728,5 +746,4 @@
 		return NULL;
 	      cd->MemForCompDict += sizeof (huff_data);
-	      cd->lens_huff[which] = hd;
 	      if (F_Read_Huffman_Data (dict, hd, &cd->MemForCompDict
 				       ,NULL) == -1)
@@ -734,4 +751,5 @@
 	      if (!(vals = Generate_Huffman_Vals (hd, &cd->MemForCompDict)))
 		return NULL;
+	      cd->lens_huff[which] = hd;
 	      cd->lens_vals[which] = vals;
 	      if (hd->clens)
@@ -807,5 +825,5 @@
   Fread (cd, sizeof (u_char), mem, text_fast_comp_dict);
 
-  if (!(fixup = (u_char *) Xmalloc (fixup_mem)))
+  if (!(fixup = new u_char[fixup_mem]))
     {
       mg_errno = MG_NOMEM;
@@ -870,5 +888,5 @@
   NTOHSI(cd->fast_loaded);
 
-  Xfree (fixup);
+  delete fixup;
   return (cd);
 }
@@ -897,5 +915,5 @@
   if (cd->fast_loaded)
     {
-      Xfree (cd);
+      delete cd;
       return;
     }
@@ -903,29 +921,29 @@
     {
       if (cd->cfh[which])
-	Xfree (cd->cfh[which]);
+	delete cd->cfh[which];
       if (cd->chars_huff[which])
-	Xfree (cd->chars_huff[which]);
+	delete cd->chars_huff[which];
       if (cd->lens_huff[which])
-	Xfree (cd->lens_huff[which]);
+	delete cd->lens_huff[which];
       if (cd->values[which])
 	{
-	  Xfree (cd->values[which][0][0]); /* [RJM 07/98: Memory Leak] */
-	  Xfree (cd->values[which][0]);
-	  Xfree (cd->values[which]);
+	  delete (cd->values[which][0][0]); /* [RJM 07/98: Memory Leak] */
+	  delete cd->values[which][0];
+	  delete (cd->values[which]);
 	}
       if (cd->chars_vals[which])
 	{
-	  Xfree (cd->chars_vals[which][0]);
-	  Xfree (cd->chars_vals[which]);
+	  delete cd->chars_vals[which][0];
+	  delete cd->chars_vals[which];
 	}
       if (cd->lens_vals[which])
 	{
-	  Xfree (cd->lens_vals[which][0]);
-	  Xfree (cd->lens_vals[which]);
+	  delete cd->lens_vals[which][0];
+	  delete cd->lens_vals[which];
 	}
     }
   if (cd->ad)
     FreeAuxDict (cd->ad);
-  Xfree (cd);
+  delete cd;
 }
 
Index: trunk/gsdl/src/mgpp/text/weights.cpp
===================================================================
--- trunk/gsdl/src/mgpp/text/weights.cpp	(revision 710)
+++ trunk/gsdl/src/mgpp/text/weights.cpp	(revision 711)
@@ -43,4 +43,7 @@
 /*
    $Log$
+   Revision 1.2  1999/10/17 23:43:31  cs025
+   Changes to eradicate Xmalloc
+
    Revision 1.1  1999/10/11 02:58:41  cs025
    Base install of MG-PP
@@ -68,5 +71,5 @@
   int num;
 
-  if (!(awd = (approx_weights_data *) Xmalloc (sizeof (*awd))))
+  if (!(awd = new approx_weights_data))
     {
       mg_errno = MG_NOMEM;
@@ -84,7 +87,7 @@
 
   num = (num_of_docs * awd->bits + 31) / 32;
-  if (!(awd->DocWeights = (long unsigned int *) Xmalloc (sizeof (unsigned long) * num)))
+  if (!(awd->DocWeights = new (unsigned long)[num]))
     {
-      Xfree (awd);
+      delete awd;
       mg_errno = MG_NOMEM;
       return (NULL);
@@ -107,5 +110,5 @@
     {
       int i, size = (1 << awd->bits);
-      if (!(awd->table = (float *) Xmalloc (size * sizeof (float))))
+      if (!(awd->table = new float[size]))
 	  return (awd);
       awd->table[0] = awd->L;
@@ -155,8 +158,8 @@
 FreeWeights (approx_weights_data * awd)
 {
-  Xfree (awd->DocWeights);
+  delete (awd->DocWeights);
   if (awd->table)
-    Xfree (awd->table);
-  Xfree (awd);
+    delete (awd->table);
+  delete awd;
 }
 
