Changeset 711 for trunk/gsdl/src
- Timestamp:
- 1999-10-18T12:43:31+13:00 (25 years ago)
- Location:
- trunk/gsdl/src/mgpp/text
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/mgpp/text/DocEntry.cpp
r655 r711 40 40 if (de->CompTextBuffer) 41 41 { 42 Xfree (de->CompTextBuffer);42 delete de->CompTextBuffer; 43 43 de->CompTextBuffer = NULL; 44 44 return de->Len; -
trunk/gsdl/src/mgpp/text/StemBlock.cpp
r655 r711 45 45 int abortvar; 46 46 47 if (!(sd = (stemmed_dict *) Xmalloc (sizeof (stemmed_dict))))47 if (!(sd = new stemmed_dict)) 48 48 { 49 49 abort(0); … … 66 66 NTOHUL(sd->sdh.indexed); 67 67 68 if (!(buffer = (u_char *) Xmalloc (sd->sdh.index_chars)))68 if (!(buffer = new u_char[sd->sdh.index_chars])) 69 69 { 70 70 abort(1); … … 72 72 sd->MemForStemDict += sd->sdh.index_chars; 73 73 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])) 75 75 { 76 76 abort(2); … … 78 78 sd->MemForStemDict += sd->sdh.num_blocks * sizeof (*sd->index); 79 79 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])) 81 81 { 82 82 abort(3); … … 84 84 sd->MemForStemDict += sd->sdh.num_blocks * sizeof (*sd->pos); 85 85 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])) 87 87 { 88 88 abort(4); … … 95 95 { 96 96 register u_char len; 97 // Read an MG string from the blocked dictionary 97 98 sd->index[i] = buffer; 98 99 len = Getc (stem_file); … … 100 101 Fread (buffer, sizeof (u_char), len, stem_file); 101 102 buffer += len; 103 104 // Read the pointer into the blocks 102 105 Fread (&sd->pos[i], sizeof (*sd->pos), 1, stem_file); 106 103 107 NTOHUL(sd->pos[i]); /* [RPAP - Jan 97: Endian Ordering] */ 104 108 } … … 114 118 { 115 119 case 4: 116 Xfree (sd->buffer);120 delete sd->pos; 117 121 case 3: 118 Xfree (sd->index);122 delete sd->index; 119 123 case 2: 120 Xfree (buffer);124 delete buffer; 121 125 case 1: 122 Xfree (sd);126 delete sd; 123 127 break; 124 128 … … 158 162 159 163 /* [RPAP - Jan 97: Endian Ordering] */ 164 // first_word is the word number of the first word in the block 160 165 *first_word = (unsigned long *) (sd->buffer); 161 166 NTOHUL(**first_word); 167 162 168 *last_invf_len = (unsigned long *) ((*first_word) + 1); 163 169 NTOHUL(**last_invf_len); 170 171 // num_words is the number of words in the block 164 172 *num_words = (unsigned short *) ((*last_invf_len) + 1); 165 173 NTOHUS(**num_words); 174 166 175 *index = (*num_words) + 1; 167 176 *num_indexes = (((**num_words) - 1) / sd->sdh.lookback) + 1; -
trunk/gsdl/src/mgpp/text/StemIdx.cpp
r655 r711 22 22 int abortvar; 23 23 24 if (!(si = (stemmed_idx *) Xmalloc (sizeof (stemmed_idx))))24 if (!(si = new stemmed_idx)) 25 25 { 26 26 abort(0); … … 43 43 NTOHUL(si->sih.num_of_words); 44 44 45 if (!(buffer = (u_char *) Xmalloc (si->sih.index_chars)))45 if (!(buffer = new u_char[si->sih.index_chars])) 46 46 { 47 47 abort(1); … … 49 49 si->MemForStemIdx += si->sih.index_chars; 50 50 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])) 52 52 { 53 53 abort(2); … … 55 55 si->MemForStemIdx += si->sih.num_blocks * sizeof (*si->index); 56 56 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])) 58 58 { 59 59 abort(3); … … 61 61 si->MemForStemIdx += si->sih.num_blocks * sizeof (*si->pos); 62 62 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])) 64 64 { 65 65 abort(4); … … 86 86 { 87 87 case 4: 88 Xfree(si->pos);88 delete si->pos; 89 89 case 3: 90 Xfree(si->index);90 delete si->index; 91 91 case 2: 92 Xfree(buffer);92 delete buffer; 93 93 case 1: 94 Xfree(si);94 delete si; 95 95 break; 96 96 } -
trunk/gsdl/src/mgpp/text/backend.cpp
r655 r711 283 283 if (textname == NULL) textname = name; /* [RJM 06/97: text filename] */ 284 284 285 if (!(qd = (query_data *) Xmalloc (sizeof (query_data))))285 if (!(qd = new query_data)) 286 286 { 287 287 abort(0); … … 326 326 { 327 327 /* [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])) 330 330 { 331 331 abort(1); … … 338 338 { 339 339 /* [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])) 342 342 { 343 343 abort(1); … … 509 509 510 510 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]; 512 512 qd->paragraph[0] = 0; 513 513 for (i = 1; i <= qd->td->cth.num_of_docs; i++) … … 545 545 size = ftell (f); 546 546 fseek (f, 0, 0); 547 trec_ids = Xmalloc (size);547 trec_ids = new char[size]; 548 548 if (!trec_ids) 549 549 { … … 557 557 int i, d; 558 558 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]; 560 560 if (!trec_paras) 561 561 { 562 Xfree (trec_ids);562 delete trec_ids; 563 563 trec_ids = NULL; 564 564 goto error; … … 595 595 error: 596 596 if (trec_ids) 597 Xfree (trec_ids);597 delete trec_ids; 598 598 if (trec_paras) 599 Xfree (trec_paras);599 delete (trec_paras); 600 600 trec_ids = NULL; 601 601 trec_paras = NULL; … … 629 629 close_all_files (qd); 630 630 case 2: 631 Xfree (qd->textpathname); /* [RJM 06/97: text filename] */631 delete (qd->textpathname); /* [RJM 06/97: text filename] */ 632 632 case 1: 633 633 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; 636 636 break; 637 637 } … … 679 679 #if defined(PARADOCNUM) || defined(NZDL) 680 680 if (qd->paragraph != NULL) { 681 Xfree (qd->paragraph);681 delete (qd->paragraph); 682 682 qd->paragraph = NULL; 683 683 } … … 696 696 FreeStemDict (qd->sd); 697 697 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); 700 700 QueryData_FreeQueryDocs (qd); 701 701 if (qd->TL != NULL) TermList_destroy(&qd->TL); /* [RJM 07/98: Memory Leak] */ 702 702 if (qd->QTL != NULL) QueryTermList_free(&qd->QTL); /* [RJM 07/98: Memory Leak] */ 703 Xfree (qd);703 delete qd; 704 704 705 705 /* other global stuff hanging around */ … … 777 777 if (qd->TextBuffer) 778 778 { 779 Xfree (qd->TextBuffer);779 delete qd->TextBuffer; 780 780 ChangeMemInUse (qd, -qd->TextBufferLen); 781 781 } … … 799 799 if (qd->DL->DE[i].CompTextBuffer) 800 800 { 801 Xfree (qd->DL->DE[i].CompTextBuffer);801 delete qd->DL->DE[i].CompTextBuffer; 802 802 qd->DL->DE[i].CompTextBuffer = NULL; 803 803 ChangeMemInUse (qd, -qd->DL->DE[i].Len); … … 903 903 qd->TextBufferLen = (int) (qd->td->cth.ratio * 1.01 * 904 904 DocEntry_length(DE)) + 100; 905 if (!(qd->TextBuffer = (unsigned char *) Xmalloc (qd->TextBufferLen)))905 if (!(qd->TextBuffer = new unsigned char[qd->TextBufferLen])) 906 906 { 907 907 fprintf (stderr, "No memory for TextBuffer\n"); -
trunk/gsdl/src/mgpp/text/bool_optimiser.cpp
r655 r711 24 24 /* 25 25 $Log$ 26 Revision 1.2 1999/10/17 23:43:22 cs025 27 Changes to eradicate Xmalloc 28 26 29 Revision 1.1 1999/10/11 02:57:01 cs025 27 30 Base install of MG-PP … … 159 162 BOOL_SIBLING (not_tree) = sibling; 160 163 161 Xfree (child);162 Xfree (a);164 delete (child); 165 delete (a); 163 166 164 167 } … … 436 439 437 440 bcopy ((void *) child, (void *) tree, sizeof (bool_tree_node)); 438 Xfree (child);441 delete (child); 439 442 BOOL_SIBLING (last) = next; 440 443 … … 475 478 BOOL_TAG (tree) = N_none; 476 479 BOOL_CHILD (tree) = NULL; 477 Xfree (child);480 delete (child); 478 481 break; 479 482 } … … 484 487 BOOL_TAG (tree) = N_all; 485 488 BOOL_CHILD (tree) = NULL; 486 Xfree (child);489 delete (child); 487 490 break; 488 491 } … … 544 547 } 545 548 546 Xfree (child);549 delete (child); 547 550 child = sibling; 548 551 } … … 571 574 bcopy ((void *) child, (void *) and_tree, sizeof (bool_tree_node)); 572 575 BOOL_SIBLING (and_tree) = save_sibling; 573 Xfree (child);576 delete (child); 574 577 } 575 578 … … 613 616 BOOL_SIBLING (prev) = sibling; 614 617 } 615 Xfree (child);618 delete (child); 616 619 child = sibling; 617 620 … … 641 644 bcopy ((void *) child, (void *) or_tree, sizeof (bool_tree_node)); 642 645 BOOL_SIBLING (or_tree) = save_sibling; 643 Xfree (child);646 delete (child); 644 647 } 645 648 … … 726 729 bool_tree_node *c = BOOL_CHILD (n); 727 730 next = BOOL_SIBLING (n); 728 Xfree (n);731 delete (n); 729 732 if (next) 730 733 BOOL_SIBLING (c) = BOOL_CHILD (next); … … 885 888 } 886 889 887 if (!(list = (bool_tree_node **) Xmalloc (sizeof (bool_tree_node *) * count)))890 if (!(list = new (bool_tree_node *)[count])) 888 891 return; 889 892 … … 904 907 BOOL_SIBLING (list[count - 1]) = NULL; 905 908 BOOL_CHILD (and_tree) = list[0]; 906 Xfree (list);909 delete list; 907 910 /* ----------------------------------------------------- */ 908 911 -
trunk/gsdl/src/mgpp/text/bool_parser.cpp
r655 r711 231 231 { 232 232 static char word[MAXSTEMLEN + 1]; /* [RJM 07/98: Memory Leak] */ 233 char *sWord = (char *) Xmalloc(MAXSTEMLEN + 1);233 char *sWord = new char[MAXSTEMLEN + 1]; 234 234 int stem_to_apply, method_using = -1; 235 235 … … 270 270 yylval.text = word; 271 271 *ptr = buf_ptr; /* fix up ptr */ 272 Xfree (sWord);272 delete sWord; 273 273 return TERM; 274 274 } … … 282 282 /* [RPAP - Feb 97: Term Frequency] */ 283 283 int i, freq = 0; 284 for (i = 0; i < Terms-> size(); i++)284 for (i = 0; i < Terms->num; i++) 285 285 freq += Terms->TE[i].WE.count; 286 286 QueryTermList_AddQueryTerm (query_term_list, (unsigned char *) word, freq, method_using); 287 287 288 Xfree (sWord);288 delete sWord; 289 289 mode = 1; 290 290 return '('; … … 293 293 { 294 294 /* Word does not exists - include in tree anyway */ 295 Xfree (sWord);295 delete sWord; 296 296 297 297 /* [RPAP - Feb 97: Term Frequency] */ … … 339 339 else /* mode == 2 */ 340 340 { 341 if (termnum >= Terms-> size())341 if (termnum >= Terms->num) 342 342 { 343 343 mode = 0; -
trunk/gsdl/src/mgpp/text/bool_tester.cpp
r655 r711 24 24 /* 25 25 $Log$ 26 Revision 1.2 1999/10/17 23:43:23 cs025 27 Changes to eradicate Xmalloc 28 26 29 Revision 1.1 1999/10/11 02:57:06 cs025 27 30 Base install of MG-PP … … 76 79 #define STEM_METHOD 3 77 80 78 static FILE *file_in = stdin; 79 static FILE *file_out = stdout; 81 #define FILE_IN stdin 82 #define FILE_OUT stdout 80 83 static char line[MAX_LINE_LEN + 1]; 81 84 … … 147 150 if (res == 0) 148 151 { 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); 152 155 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); 156 159 } 157 160 … … 170 173 prompt (char *str) 171 174 { 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); 174 177 } -
trunk/gsdl/src/mgpp/text/bool_tree.cpp
r655 r711 41 41 { 42 42 bool_tree_node *n; 43 if (!(n = (bool_tree_node *) Xmalloc (sizeof (bool_tree_node))))43 if (!(n = new bool_tree_node)) 44 44 FatalError (1, "Can not create bool_tree_node for boolean query"); 45 45 n->tag = tag; … … 125 125 FreeTree (BOOL_CHILD (tree)); 126 126 sibling = BOOL_SIBLING (tree); 127 Xfree (tree);127 delete (tree); 128 128 tree = sibling; 129 129 } -
trunk/gsdl/src/mgpp/text/commands.cpp
r655 r711 24 24 /* 25 25 $Log$ 26 Revision 1.2 1999/10/17 23:43:24 cs025 27 Changes to eradicate Xmalloc 28 26 29 Revision 1.1 1999/10/11 02:57:08 cs025 27 30 Base install of MG-PP … … 241 244 242 245 /* join the two parameters together */ 243 buf = (char *) Xmalloc (strlen (param1) + strlen (param2) + 1);246 buf = new char[strlen (param1) + strlen (param2) + 1]; 244 247 strcpy (buf, param1); 245 248 strcat (buf, param2); … … 268 271 InPipe = 0; 269 272 InFile = stdin; 270 Xfree (buf);273 delete buf; 271 274 return; 272 275 } … … 303 306 InFile = stdin; 304 307 } 305 Xfree (buf);308 delete buf; 306 309 } 307 310 … … 320 323 321 324 /* join the two parameters together */ 322 buf = (char *) Xmalloc (strlen (param1) + strlen (param2) + 1);325 buf = new char[strlen (param1) + strlen (param2) + 1]; 323 326 strcpy (buf, param1); 324 327 strcat (buf, param2); … … 350 353 OutPipe = 0; 351 354 OutFile = stdout; 352 Xfree (buf);355 delete buf; 353 356 return; 354 357 } … … 384 387 OutFile = stdout; 385 388 } 386 Xfree (buf);389 delete buf; 387 390 } 388 391 -
trunk/gsdl/src/mgpp/text/grbIndex.cpp
r659 r711 24 24 /* 25 25 $Log$ 26 Revision 1.4 1999/10/17 23:43:24 cs025 27 Changes to eradicate Xmalloc 28 26 29 Revision 1.3 1999/10/12 04:13:11 cs025 27 30 Changes made to eradicate use of GetEnv elsewhere. … … 184 187 { 185 188 if (Stats[i].name) 186 Xfree (Stats[i].name);189 delete Stats[i].name; 187 190 if (Stats[i].text) 188 Xfree (Stats[i].text);191 delete Stats[i].text; 189 192 } 190 193 Xfree (Stats); … … 483 486 if (post_proc) 484 487 { 485 Xfree (post_proc);488 delete post_proc; 486 489 post_proc = NULL; 487 490 } … … 940 943 if (OutputType == OUTPUT_TEXT || OutputType == OUTPUT_HILITE) 941 944 { 942 Xfree (doc_sepstr);943 Xfree (para_sepstr);944 Xfree (para_start);945 delete doc_sepstr; 946 delete para_sepstr; 947 delete para_start; 945 948 } 946 949 … … 955 958 de_escape_string (terminator); 956 959 fputs (terminator, out); 957 Xfree (terminator);960 delete terminator; 958 961 } 959 962 -
trunk/gsdl/src/mgpp/text/mg_invf_rebuild.cpp
r655 r711 50 50 /* 51 51 $Log$ 52 Revision 1.2 1999/10/17 23:43:26 cs025 53 Changes to eradicate Xmalloc 54 52 55 Revision 1.1 1999/10/11 02:57:58 cs025 53 56 Base install of MG-PP … … 355 358 for (i = 0; i < ifh_in.no_of_words; i++) 356 359 { 357 unsigned long blk, p;360 unsigned long blk, docCount; 358 361 unsigned long odn_blk = 0, olen_blk = 0; 359 362 unsigned long idn_blk = 0, ilen_blk = 0; … … 374 377 NTOHUL(bytes_out); /* [RPAP - Jan 97: Endian Ordering] */ 375 378 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); 378 381 switch (outmode) 379 382 { … … 381 384 { 382 385 unsigned long len; 383 if ( p<= ifh_out.params[0])386 if (docCount <= ifh_out.params[0]) 384 387 out_k = 0; 385 388 else 386 389 { 387 390 out_k = ifh_out.params[0]; 388 len = BIO_Bblock_Bound (N, p);391 len = BIO_Bblock_Bound (N, docCount); 389 392 if (ifh_in.InvfLevel >= 2) 390 393 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); 393 396 } 394 397 break; … … 397 400 { 398 401 unsigned long len; 399 if ( p<= mins)402 if (docCount <= mins) 400 403 out_k = 0; 401 404 else 402 405 { 403 out_k = (int) (2 * sqrt ((double) p/ max_nodes));406 out_k = (int) (2 * sqrt ((double) docCount / max_nodes)); 404 407 if (out_k <= mins) 405 408 out_k = mins; 406 len = BIO_Bblock_Bound (N, p);409 len = BIO_Bblock_Bound (N, docCount); 407 410 if (ifh_in.InvfLevel >= 2) 408 411 len += word.words(); 409 412 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); 412 415 } 413 416 break; … … 422 425 { 423 426 unsigned long len; 424 if ( p<= ifh_in.params[0])427 if (docCount <= ifh_in.params[0]) 425 428 in_k = 0; 426 429 else 427 430 { 428 431 in_k = ifh_in.params[0]; 429 len = BIO_Bblock_Bound (N, p);432 len = BIO_Bblock_Bound (N, docCount); 430 433 if (ifh_in.InvfLevel >= 2) 431 434 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); 434 437 } 435 438 break; … … 438 441 { 439 442 unsigned long len; 440 if ( p<= ifh_in.params[1])443 if (docCount <= ifh_in.params[1]) 441 444 { 442 445 in_k = 0; … … 444 447 else 445 448 { 446 in_k = (int) (2 * sqrt ((double) p/ ifh_in.params[0]));449 in_k = (int) (2 * sqrt ((double) docCount / ifh_in.params[0])); 447 450 if (in_k <= ifh_in.params[1]) 448 451 in_k = ifh_in.params[1]; 449 len = BIO_Bblock_Bound (N, p);452 len = BIO_Bblock_Bound (N, docCount); 450 453 if (ifh_in.InvfLevel >= 2) 451 454 len += word.words(); 452 455 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); 455 458 } 456 459 break; … … 460 463 } 461 464 462 if (!(ii = (invf_info *) Xmalloc (sizeof (invf_info) * p)))465 if (!(ii = (invf_info *) Xmalloc (sizeof (invf_info) * docCount))) 463 466 FatalError (1, "Unable to allocate memory for \"ii\"\n"); 464 467 … … 467 470 kd = 0; 468 471 DECODE_CONTINUE (in_buf) 469 for (j = 0; j < p; j++, kd++)472 for (j = 0; j < docCount; j++, kd++) 470 473 { 471 474 unsigned long doc_diff, count = 0; 472 475 if (kd == in_k) 473 476 kd = 0; 474 if (in_k && kd == 0 && j + in_k < p)477 if (in_k && kd == 0 && j + in_k < docCount) 475 478 { 476 479 int temp; … … 480 483 } 481 484 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) 483 486 { 484 487 int count; … … 517 520 kd = 0; 518 521 ENCODE_CONTINUE (out_buf) 519 for (j = 0; j < p; j++, kd++)522 for (j = 0; j < docCount; j++, kd++) 520 523 { 521 524 if (kd == out_k) … … 523 526 if (out_k && kd == 0) 524 527 { 525 if (j + out_k < p)528 if (j + out_k < docCount) 526 529 { 527 530 int num = ii[j + out_k - 1].doc_num - last_major; … … 535 538 } 536 539 } 537 if (!(out_k && kd == out_k - 1 && j != p- 1))540 if (!(out_k && kd == out_k - 1 && j != docCount - 1)) 538 541 buffer.bblock_encode (ii[j].doc_num - doc_num, blk, &bits_out); 539 542 doc_num = ii[j].doc_num; -
trunk/gsdl/src/mgpp/text/mgdictlist.cpp
r655 r711 37 37 /* 38 38 $Log$ 39 Revision 1.2 1999/10/17 23:43:27 cs025 40 Changes to eradicate Xmalloc 41 39 42 Revision 1.1 1999/10/11 02:58:08 cs025 40 43 Base install of MG-PP … … 195 198 cfh.hd.maxcodelen, code, word2str (prev)); 196 199 } 197 Xfree (codes);198 Xfree (cfh.hd.clens);200 delete codes; 201 delete cfh.hd.clens; 199 202 } 200 203 … … 232 235 } 233 236 } 234 Xfree (codes);235 Xfree (hd.clens);237 delete codes; 238 delete hd.clens; 236 239 } 237 240 -
trunk/gsdl/src/mgpp/text/mgquery.cpp
r658 r711 24 24 /* 25 25 $Log$ 26 Revision 1.4 1999/10/17 23:43:28 cs025 27 Changes to eradicate Xmalloc 28 26 29 Revision 1.3 1999/10/12 04:12:46 cs025 27 30 Changes made to assist with eradication of GetEnv elsewhere in the … … 187 190 { 188 191 if (Stats[i].name) 189 Xfree (Stats[i].name);192 delete Stats[i].name; 190 193 if (Stats[i].text) 191 Xfree (Stats[i].text);194 delete Stats[i].text; 192 195 } 193 196 Xfree (Stats); … … 486 489 if (post_proc) 487 490 { 488 Xfree (post_proc);491 delete post_proc; 489 492 post_proc = NULL; 490 493 } … … 965 968 if (OutputType == OUTPUT_TEXT || OutputType == OUTPUT_HILITE) 966 969 { 967 Xfree (doc_sepstr);968 Xfree (para_sepstr);969 Xfree (para_start);970 delete doc_sepstr; 971 delete para_sepstr; 972 delete para_start; 970 973 } 971 974 … … 980 983 de_escape_string (terminator); 981 984 fputs (terminator, out); 982 Xfree (terminator);985 delete terminator; 983 986 } 984 987 -
trunk/gsdl/src/mgpp/text/query.ranked.cpp
r660 r711 51 51 /* 52 52 $Log$ 53 Revision 1.3 1999/10/17 23:43:29 cs025 54 Changes to eradicate Xmalloc 55 53 56 Revision 1.2 1999/10/12 04:13:52 cs025 54 57 Calls to GetEnv eradicated; interface to parsing of query text … … 128 131 int MaxSize; 129 132 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 } 131 145 } 132 146 Heap; … … 137 151 { 138 152 Heap *H; 139 H = (Heap *) Xmalloc (sizeof (Heap) + (size - 1) * sizeof (HeapEntry));153 H = new Heap(size); 140 154 if (!H) 141 155 return NULL; … … 644 658 document weights which we retrieve from the ".idx.wgt" file and put 645 659 the resulting data into a heap */ 646 647 648 660 he = H->HE; 649 661 H->NumItems = MaxDocs; … … 805 817 } 806 818 807 808 819 if (rqi->Exact && qd->id->ifh.InvfLevel != 3) 809 820 { … … 957 968 } 958 969 } 959 960 961 970 962 971 H->HC = Heap_Greater; … … 1062 1071 LT_free (qd, LT); 1063 1072 1064 if (H) Xfree (H); /* [RJM 07/98: Memory Leak] */1073 if (H) delete H; /* [RJM 07/98: Memory Leak] */ 1065 1074 1066 1075 return (Docs); -
trunk/gsdl/src/mgpp/text/read_line.cpp
r655 r711 83 83 static void memory_error_and_abort (); 84 84 85 char * 86 xmalloc (bytes) 87 int bytes; 88 { 89 char *temp = (char *) Xmalloc (bytes); 85 void * 86 xmalloc (size_t bytes) 87 { 88 void *temp = Xmalloc (bytes); 90 89 91 90 if (!temp) … … 94 93 } 95 94 96 char * 97 xrealloc (pointer, bytes) 98 char *pointer; 99 int bytes; 100 { 101 char *temp; 95 void * 96 xrealloc (void *pointer, size_t bytes) 97 { 98 void *temp; 102 99 103 100 if (!pointer) 104 temp = (char *)xmalloc (bytes);101 temp = xmalloc (bytes); 105 102 else 106 temp = (char *)Xrealloc (pointer, bytes);103 temp = Xrealloc (pointer, bytes); 107 104 108 105 if (!temp) … … 150 147 static char *the_line = NULL; 151 148 if (the_line) 152 Xfree (the_line);149 delete the_line; 153 150 the_line = NULL; 154 151 rl_instream = InFile; … … 194 191 char *s; 195 192 if (line) 196 Xfree (line);193 delete line; 197 194 line = NULL; 195 198 196 if (!(s = GetLine ("> "))) 199 197 return (NULL); … … 210 208 if (!(s = GetLine ("? "))) 211 209 return (NULL); 212 if (!(newline = (char *) Xmalloc (strlen (line) + strlen (s) + 2)))210 if (!(newline = new char[strlen (line) + strlen (s) + 2])) 213 211 { 214 212 fprintf (stderr, "Unable to allocate memory for the line\n"); … … 218 216 strcat (newline, "\n"); 219 217 strcat (newline, s); 220 Xfree (line);218 delete line; 221 219 line = newline; 222 220 } -
trunk/gsdl/src/mgpp/text/stem_search.cpp
r655 r711 48 48 /* 49 49 $Log$ 50 Revision 1.2 1999/10/17 23:43:29 cs025 51 Changes to eradicate Xmalloc 52 50 53 Revision 1.1 1999/10/11 02:58:32 cs025 51 54 Base install of MG-PP … … 108 111 return (NULL); 109 112 } 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 */175 113 mg_errno = MG_NOERROR; 176 114 … … 300 238 StemBlock_read(sd, block, &first_word, &last_invf_len, &num_words, 301 239 &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]);*/320 240 } 321 241 else … … 334 254 */ 335 255 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 else348 {349 hi = mid;350 break;351 }352 }353 if (hi < 0)354 hi = 0;355 */356 256 357 257 res = hi * sd->sdh.lookback; … … 365 265 while (res < *num_words) 366 266 { 367 //unsigned copy, suff;368 267 unsigned long invfp; 369 /* if (res >= *num_words)370 return (-1);*/371 268 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 */379 269 380 270 c = casecompare (Word, prev); /* [RPAP - Jan 97: Stem Index Change] */ … … 407 297 { 408 298 /* Calculate invf_len is necessary */ 409 // unsigned long next_invfp;410 299 if (!invf_len) 411 300 return (*first_word + res); … … 421 310 /* Skip over most of the next word to get to the invf_ptr */ 422 311 *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 */431 312 return (*first_word + res); 432 313 } … … 507 388 StemIdx_block_readNext((void *) si->stem_idx_file, si, idx_block, &idx_first_word, &idx_num_words, 508 389 &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 */525 390 } 526 391 else … … 542 407 543 408 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 else556 {557 hi = mid;558 break;559 }560 }561 if (hi < 0)562 hi = 0;563 */564 409 idx_res = hi * si->sih.lookback; 565 410 idx_base += idx_index[hi]; … … 573 418 return (-1); 574 419 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 */583 420 584 421 c = casecompare (sWord, idx_prev); … … 608 445 */ 609 446 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 */624 447 625 448 … … 636 459 StemBlock_read(sd, block, &first_word, &last_invf_len, &num_words, 637 460 &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 */656 461 } 657 462 else … … 676 481 StemBlock_ReadWordString(&base, prev); 677 482 678 /*679 copy = *base++;680 suff = *base++;681 bcopy ((void *) base, (void *) (prev + copy + 1), suff);682 base += suff;683 *prev = copy + suff;684 */685 483 base += sizeof (unsigned long); /* skip doc_count */ 686 484 base += sizeof (unsigned long); /* skip count */ … … 699 497 return (-1); 700 498 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 */708 499 709 500 te.Word = copy_string (prev); … … 737 528 else 738 529 { 739 //unsigned long next_invfp;740 530 u_char *oldbase = base; 741 531 742 532 /* Skip over most of the next word to get to the invf_ptr */ 743 533 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 */752 534 base = oldbase; 753 535 } … … 764 546 if (res == *num_words - 1 && j + 1 < num_cases) 765 547 { 766 //int ii;767 548 /* Read in next block */ 768 549 block++; 769 550 StemBlock_read(sd, block, &first_word, &last_invf_len, &num_words, 770 551 &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 */789 552 base = (u_char *) (index + num_indexes); 790 553 base += index[0]; … … 811 574 FreeStemIdx (sd->stem3); 812 575 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; 818 581 } 819 582 … … 822 585 FreeStemIdx (stemmed_idx * si) 823 586 { 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 51 51 /* 52 52 $Log$ 53 Revision 1.2 1999/10/17 23:43:30 cs025 54 Changes to eradicate Xmalloc 55 53 56 Revision 1.1 1999/10/11 02:58:39 cs025 54 57 Base install of MG-PP … … 68 71 * 69 72 */ 73 74 typedef enum huff_type {lengths, chars}; 70 75 71 76 static char *RCSID = "$Id$"; … … 113 118 if (!td->idx_data) 114 119 { 115 td->idx_data = (__idx_data *) Xmalloc (sizeof (*(td->idx_data)) * MG_PAGE_SIZE);120 td->idx_data = new index_data[MG_PAGE_SIZE]; 116 121 if (!td->idx_data) 117 122 FatalError (1, "Out of memory in FDSL2"); 118 123 } 124 119 125 if (td->current_pos == -1 || DN >= td->current_pos + MG_PAGE_SIZE - 1 || 120 126 DN < td->current_pos) … … 125 131 if (rn < 1) 126 132 rn = 1; 133 127 134 Fseek (td->TextIdxWgtFile, (sizeof (unsigned long) + sizeof (float)) * 128 135 (rn - 1) + sizeof (unsigned long), 0); 136 129 137 num = Fread ((char *) td->idx_data, sizeof (*(td->idx_data)), MG_PAGE_SIZE, /* [RPAP - Jan 97: Endian Ordering] */ 130 138 td->TextIdxWgtFile); … … 219 227 DocEnt->FetchStart(qd); 220 228 // FetchDocStart (qd, DocEnt->DocNum, &DocEnt->SeekPos, &DocEnt->Len); 221 if (!(*DocBuff = (char *) Xmalloc (DocEnt->Len)))229 if (!(*DocBuff = new char[DocEnt->Len])) 222 230 return (-1); 223 231 … … 240 248 text_data *td; 241 249 242 if (!(td = (text_data *) Xmalloc (sizeof (text_data))))250 if (!(td = new text_data)) 243 251 { 244 252 mg_errno = MG_NOMEM; … … 270 278 { 271 279 if (td->idx_data) 272 Xfree (td->idx_data);273 Xfree (td);280 delete td->idx_data; 281 delete td; 274 282 } 275 283 } … … 292 300 DocEntry **pts; 293 301 int i, j; 294 if (!(pts = (DocEntry **) Xmalloc (num * sizeof (DocEntry *))))302 if (!(pts = new (DocEntry *)[num])) 295 303 { 296 304 mg_errno = MG_NOMEM; … … 309 317 } 310 318 311 Xfree (pts);319 delete pts; 312 320 return (0); 313 321 } … … 326 334 if (!num) 327 335 return (0); 328 if (!(pts = (DocEntry **) Xmalloc (num * sizeof (DocEntry *))))336 if (!(pts = new (DocEntry *)[num])) 329 337 { 330 338 mg_errno = MG_NOMEM; … … 350 358 } 351 359 352 Xfree (pts);360 delete pts; 353 361 354 362 return (i); … … 369 377 if (Docs->CompTextBuffer) 370 378 { 371 Xfree (Docs->CompTextBuffer);379 delete Docs->CompTextBuffer; 372 380 Docs->CompTextBuffer = NULL; 373 381 ChangeMemInUse (qd, -Docs->Len); … … 386 394 return; 387 395 if (ad->word_data[0]) 388 Xfree (ad->word_data[0]);396 delete ad->word_data[0]; 389 397 if (ad->word_data[1]) 390 Xfree (ad->word_data[1]);398 delete ad->word_data[1]; 391 399 if (ad->words[0]) 392 Xfree (ad->words[0]);400 delete ad->words[0]; 393 401 if (ad->words[1]) 394 Xfree (ad->words[1]);395 Xfree (ad);402 delete ad->words[1]; 403 delete ad; 396 404 } 397 405 … … 402 410 int i; 403 411 404 if (!(ad = (auxiliary_dict *) Xmalloc (sizeof (auxiliary_dict))))412 if (!(ad = new auxiliary_dict)) 405 413 { 406 414 mg_errno = MG_NOMEM; … … 421 429 NTOHUL(ad->afh[i].mem_for_frags); 422 430 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])) 424 432 { 425 433 mg_errno = MG_NOMEM; … … 427 435 return (NULL); 428 436 } 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])) 430 438 { 431 439 mg_errno = MG_NOMEM; … … 489 497 } 490 498 491 if (!(vals = (u_char **) Xmalloc (ptrs_reqd * sizeof (*vals))))499 if (!(vals = new (u_char *)[ptrs_reqd])) 492 500 return (NULL); 493 501 494 if (!(values = (u_char ***) Xmalloc ((MAX_HUFFCODE_LEN + 1) * sizeof (u_char **))))502 if (!(values = new (u_char **)[MAX_HUFFCODE_LEN + 1])) 495 503 return (NULL); 496 504 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); 498 507 499 508 cd->MemForCompDict += ptrs_reqd * sizeof (*vals) + … … 546 555 } 547 556 if (cfh->hd.clens) 548 Xfree (cfh->hd.clens);557 delete cfh->hd.clens; 549 558 cfh->hd.clens = NULL; 550 559 return values; 551 560 } 552 561 553 int Load_Comp_HuffData(compression_dict *cd, int which, File *dict) 562 int Load_Comp_HuffData(compression_dict *cd, int which, File *dict, 563 huff_type type) 554 564 { 555 565 huff_data * hd; 556 566 u_long ** vals; 557 567 558 if (!(hd = (huff_data *) Xmalloc (sizeof (huff_data))))568 if (!(hd = new huff_data)) 559 569 return 1; 560 570 cd->MemForCompDict += sizeof (huff_data); … … 564 574 return 3; 565 575 if (hd->clens) 566 Xfree (hd->clens);576 delete hd->clens; 567 577 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 } 570 588 571 589 return 0; … … 574 592 int Load_Comp_FragsHeader(compression_dict *cd, int which, int getEscape, File *dict) 575 593 { 576 if (!(cd->cfh[which] = (comp_frags_header *) Xmalloc (sizeof (*cd->cfh[which]))))594 if (!(cd->cfh[which] = new comp_frags_header)) 577 595 return 1; 578 596 cd->MemForCompDict += sizeof (*cd->cfh[which]); … … 592 610 compression_dict *cd; 593 611 594 if (!(cd = (compression_dict *) Xmalloc (sizeof (compression_dict))))612 if (!(cd = new compression_dict)) 595 613 { 596 614 mg_errno = MG_NOMEM; … … 647 665 */ 648 666 } 649 if (Load_Comp_HuffData(cd, which, dict ) != 0)667 if (Load_Comp_HuffData(cd, which, dict, chars) != 0) 650 668 return NULL; 651 669 /* … … 663 681 cd->chars_vals[which] = vals; 664 682 */ 665 if (Load_Comp_HuffData(cd, which, dict ) != 0)683 if (Load_Comp_HuffData(cd, which, dict, lengths) != 0) 666 684 return NULL; 667 685 /* … … 704 722 { 705 723 case MG_NOVEL_HUFFMAN_CHARS: 706 if (Load_Comp_HuffData(cd, which, dict ) != 0)724 if (Load_Comp_HuffData(cd, which, dict, chars) != 0) 707 725 return NULL; 708 726 /* 709 727 if (!(hd = (huff_data *) Xmalloc (sizeof (huff_data)))) 710 728 return NULL; 711 cd->chars_huff[which] = hd;712 729 cd->MemForCompDict += sizeof (huff_data); 713 730 if (F_Read_Huffman_Data (dict, hd, &cd->MemForCompDict, … … 716 733 if (!(vals = Generate_Huffman_Vals (hd, &cd->MemForCompDict))) 717 734 return NULL; 735 cd->chars_huff[which] = hd; 718 736 cd->chars_vals[which] = vals; 719 737 if (hd->clens) … … 722 740 */ 723 741 724 if (Load_Comp_HuffData(cd, which, dict ) != 0)742 if (Load_Comp_HuffData(cd, which, dict, lengths) != 0) 725 743 return NULL; 726 744 /* … … 728 746 return NULL; 729 747 cd->MemForCompDict += sizeof (huff_data); 730 cd->lens_huff[which] = hd;731 748 if (F_Read_Huffman_Data (dict, hd, &cd->MemForCompDict 732 749 ,NULL) == -1) … … 734 751 if (!(vals = Generate_Huffman_Vals (hd, &cd->MemForCompDict))) 735 752 return NULL; 753 cd->lens_huff[which] = hd; 736 754 cd->lens_vals[which] = vals; 737 755 if (hd->clens) … … 807 825 Fread (cd, sizeof (u_char), mem, text_fast_comp_dict); 808 826 809 if (!(fixup = (u_char *) Xmalloc (fixup_mem)))827 if (!(fixup = new u_char[fixup_mem])) 810 828 { 811 829 mg_errno = MG_NOMEM; … … 870 888 NTOHSI(cd->fast_loaded); 871 889 872 Xfree (fixup);890 delete fixup; 873 891 return (cd); 874 892 } … … 897 915 if (cd->fast_loaded) 898 916 { 899 Xfree (cd);917 delete cd; 900 918 return; 901 919 } … … 903 921 { 904 922 if (cd->cfh[which]) 905 Xfree (cd->cfh[which]);923 delete cd->cfh[which]; 906 924 if (cd->chars_huff[which]) 907 Xfree (cd->chars_huff[which]);925 delete cd->chars_huff[which]; 908 926 if (cd->lens_huff[which]) 909 Xfree (cd->lens_huff[which]);927 delete cd->lens_huff[which]; 910 928 if (cd->values[which]) 911 929 { 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]); 915 933 } 916 934 if (cd->chars_vals[which]) 917 935 { 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]; 920 938 } 921 939 if (cd->lens_vals[which]) 922 940 { 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]; 925 943 } 926 944 } 927 945 if (cd->ad) 928 946 FreeAuxDict (cd->ad); 929 Xfree (cd);947 delete cd; 930 948 } 931 949 -
trunk/gsdl/src/mgpp/text/weights.cpp
r655 r711 43 43 /* 44 44 $Log$ 45 Revision 1.2 1999/10/17 23:43:31 cs025 46 Changes to eradicate Xmalloc 47 45 48 Revision 1.1 1999/10/11 02:58:41 cs025 46 49 Base install of MG-PP … … 68 71 int num; 69 72 70 if (!(awd = (approx_weights_data *) Xmalloc (sizeof (*awd))))73 if (!(awd = new approx_weights_data)) 71 74 { 72 75 mg_errno = MG_NOMEM; … … 84 87 85 88 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])) 87 90 { 88 Xfree (awd);91 delete awd; 89 92 mg_errno = MG_NOMEM; 90 93 return (NULL); … … 107 110 { 108 111 int i, size = (1 << awd->bits); 109 if (!(awd->table = (float *) Xmalloc (size * sizeof (float))))112 if (!(awd->table = new float[size])) 110 113 return (awd); 111 114 awd->table[0] = awd->L; … … 155 158 FreeWeights (approx_weights_data * awd) 156 159 { 157 Xfree (awd->DocWeights);160 delete (awd->DocWeights); 158 161 if (awd->table) 159 Xfree (awd->table);160 Xfree (awd);162 delete (awd->table); 163 delete awd; 161 164 } 162 165
Note:
See TracChangeset
for help on using the changeset viewer.