comparison src/tc-rep.cc @ 1168:e2036dce97ea

[project @ 1995-03-10 18:49:55 by jwe]
author jwe
date Fri, 10 Mar 1995 18:50:02 +0000
parents 75fc98220389
children 9963da2d3755
comparison
equal deleted inserted replaced
1167:364906259d4a 1168:e2036dce97ea
47 #include "idx-vector.h" 47 #include "idx-vector.h"
48 #include "oct-map.h" 48 #include "oct-map.h"
49 49
50 #include "tc-inlines.h" 50 #include "tc-inlines.h"
51 51
52 // The following three variables could be made static members of the
53 // TC_REP class.
54
55 // Pointer to the blocks of memory we manage.
56 static TC_REP *newlist;
57
58 // Multiplier for allocating new blocks.
59 static const int newlist_grow_size = 128;
60
61 // Pointer to the last element of the last block allocated.
62 static TC_REP *newlist_tail = 0;
63
52 static int 64 static int
53 any_element_is_complex (const ComplexMatrix& a) 65 any_element_is_complex (const ComplexMatrix& a)
54 { 66 {
55 int nr = a.rows (); 67 int nr = a.rows ();
56 int nc = a.columns (); 68 int nc = a.columns ();
444 } 456 }
445 457
446 delete [] orig_text; 458 delete [] orig_text;
447 } 459 }
448 460
449 #if defined (MDEBUG)
450 void * 461 void *
451 TC_REP::operator new (size_t size) 462 TC_REP::operator new (size_t size)
452 { 463 {
453 tree_constant_rep *p = ::new tree_constant_rep; 464 assert (size == sizeof (TC_REP));
454 cerr << "TC_REP::new(): " << p << "\n"; 465
455 return p; 466 if (! newlist)
467 {
468 int block_size = newlist_grow_size * sizeof (TC_REP);
469 newlist = (TC_REP *) new char [block_size];
470
471 for (int i = 0; i < newlist_grow_size - 1; i++)
472 newlist[i].freeptr = &newlist[i+1];
473
474 newlist[i].freeptr = 0;
475
476 if (newlist_tail)
477 newlist_tail->freeptr = newlist;
478
479 newlist_tail = &newlist[i];
480 }
481
482 TC_REP *tmp = newlist;
483 newlist = newlist->freeptr;
484 return tmp;
456 } 485 }
457 486
458 void 487 void
459 TC_REP::operator delete (void *p, size_t size) 488 TC_REP::operator delete (void *p, size_t size)
460 { 489 {
461 cerr << "TC_REP::delete(): " << p << "\n"; 490 TC_REP *tmp = (TC_REP *) p;
462 ::delete p; 491 tmp->freeptr = newlist;
463 } 492 newlist = tmp;
464 #endif 493 }
465 494
466 int 495 int
467 TC_REP::rows (void) const 496 TC_REP::rows (void) const
468 { 497 {
469 int retval = -1; 498 int retval = -1;