Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
3.0 KiB

  1. /**************************************************************************
  2. * *
  3. * Copyright (C) 1992, Silicon Graphics, Inc. *
  4. * *
  5. * These coded instructions, statements, and computer programs contain *
  6. * unpublished proprietary information of Silicon Graphics, Inc., and *
  7. * are protected by Federal copyright law. They may not be disclosed *
  8. * to third parties or copied or duplicated in any form, in whole or *
  9. * in part, without the prior written consent of Silicon Graphics, Inc. *
  10. * *
  11. **************************************************************************/
  12. /*
  13. * trimvertexpool.c++ - $Revision: 1.1 $
  14. * Derrick Burns - 1991
  15. */
  16. #include "glimport.h"
  17. #include "myassert.h"
  18. #include "mystdio.h"
  19. #include "mystring.h"
  20. #include "trimvert.h"
  21. #include "trimpool.h"
  22. #include "bufpool.h"
  23. /*----------------------------------------------------------------------------
  24. * TrimVertexPool::TrimVertexPool
  25. *----------------------------------------------------------------------------
  26. */
  27. TrimVertexPool::TrimVertexPool( void )
  28. : pool( sizeof(TrimVertex)*3, 32, "Threevertspool" )
  29. {
  30. // initialize array of pointers to vertex lists
  31. nextvlistslot = 0;
  32. vlistsize = INIT_VERTLISTSIZE;
  33. vlist = new TrimVertex_p[vlistsize];
  34. }
  35. /*----------------------------------------------------------------------------
  36. * TrimVertexPool::~TrimVertexPool
  37. *----------------------------------------------------------------------------
  38. */
  39. TrimVertexPool::~TrimVertexPool( void )
  40. {
  41. // free all arrays of TrimVertices vertices
  42. while( nextvlistslot ) {
  43. delete vlist[--nextvlistslot];
  44. }
  45. // reallocate space for array of pointers to vertex lists
  46. if( vlist ) delete[] vlist;
  47. }
  48. /*----------------------------------------------------------------------------
  49. * TrimVertexPool::clear
  50. *----------------------------------------------------------------------------
  51. */
  52. void
  53. TrimVertexPool::clear( void )
  54. {
  55. // reinitialize pool of 3 vertex arrays
  56. pool.clear();
  57. // free all arrays of TrimVertices vertices
  58. while( nextvlistslot ) {
  59. delete vlist[--nextvlistslot];
  60. vlist[nextvlistslot] = 0;
  61. }
  62. // reallocate space for array of pointers to vertex lists
  63. if( vlist ) delete[] vlist;
  64. vlist = new TrimVertex_p[vlistsize];
  65. }
  66. /*----------------------------------------------------------------------------
  67. * TrimVertexPool::get - allocate a vertex list
  68. *----------------------------------------------------------------------------
  69. */
  70. TrimVertex *
  71. TrimVertexPool::get( int n )
  72. {
  73. TrimVertex *v;
  74. if( n == 3 ) {
  75. v = (TrimVertex *) pool.new_buffer();
  76. } else {
  77. if( nextvlistslot == vlistsize ) {
  78. vlistsize *= 2;
  79. TrimVertex_p *nvlist = new TrimVertex_p[vlistsize];
  80. memcpy( nvlist, vlist, nextvlistslot * sizeof(TrimVertex_p) );
  81. if( vlist ) delete[] vlist;
  82. vlist = nvlist;
  83. }
  84. v = vlist[nextvlistslot++] = new TrimVertex[n];
  85. }
  86. return v;
  87. }