Source code of Windows XP (NT5)
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.

173 lines
4.3 KiB

  1. /*
  2. ** Copyright 1992, Silicon Graphics, Inc.
  3. ** All Rights Reserved.
  4. **
  5. ** This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6. ** the contents of this file may not be disclosed to third parties, copied or
  7. ** duplicated in any form, in whole or in part, without the prior written
  8. ** permission of Silicon Graphics, Inc.
  9. **
  10. ** RESTRICTED RIGHTS LEGEND:
  11. ** Use, duplication or disclosure by the Government is subject to restrictions
  12. ** as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13. ** and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14. ** successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15. ** rights reserved under the Copyright Laws of the United States.
  16. **
  17. */
  18. #include <stdlib.h>
  19. #include <setjmp.h>
  20. struct JumpBuffer {
  21. jmp_buf buf;
  22. };
  23. #define mysetjmp(x) setjmp((x)->buf)
  24. #define mylongjmp(x,y) longjmp((x)->buf, y)
  25. /* <<AT&T USL C++ Language System <3.0.1> 02/03/92>> */
  26. /* < ../core/bufpool.c++ > */
  27. void *__vec_new (void *, int , int , void *);
  28. void __vec_ct (void *, int , int , void *);
  29. void __vec_dt (void *, int , int , void *);
  30. void __vec_delete (void *, int , int , void *, int , int );
  31. typedef int (*__vptp)(void);
  32. struct __mptr {short d; short i; __vptp f; };
  33. typedef unsigned int size_t ;
  34. // extern void *malloc (size_t );
  35. // extern void free (void *);
  36. struct Buffer;
  37. struct Buffer {
  38. struct Buffer *next__6Buffer ;
  39. };
  40. struct Pool;
  41. enum __Q2_4Pool5Magic { is_allocated__Q2_4Pool5Magic = 62369, is_free__Q2_4Pool5Magic = 61858} ;
  42. struct Pool {
  43. struct Buffer *freelist__4Pool ;
  44. char *blocklist__4Pool [32];
  45. int nextblock__4Pool ;
  46. char *curblock__4Pool ;
  47. int buffersize__4Pool ;
  48. int nextsize__4Pool ;
  49. int nextfree__4Pool ;
  50. int initsize__4Pool ;
  51. char *name__4Pool ;
  52. int magic__4Pool ;
  53. };
  54. void __glgrow__4PoolFv (struct Pool *);
  55. struct PooledObj;
  56. struct PooledObj {
  57. char __W3__9PooledObj ;
  58. };
  59. extern struct __mptr* __ptbl_vec_____core_bufpool_c_____ct_[];
  60. struct Pool *__gl__ct__4PoolFiT1Pc (struct Pool *__0this , int __1_buffersize , int __1initpoolsize , char *__1n )
  61. {
  62. void *__1__Xp00uzigaiaa ;
  63. if (__0this || (__0this = (struct Pool *)( (__1__Xp00uzigaiaa = malloc ( (sizeof (struct Pool))) ), (__1__Xp00uzigaiaa ?(((void *)__1__Xp00uzigaiaa )):(((void *)__1__Xp00uzigaiaa )))) )){
  64. __0this -> buffersize__4Pool = ((__1_buffersize < (sizeof (struct Buffer )))?(sizeof (struct Buffer )):(((unsigned int )__1_buffersize )));
  65. __0this -> initsize__4Pool = (__1initpoolsize * __0this -> buffersize__4Pool );
  66. __0this -> nextsize__4Pool = __0this -> initsize__4Pool ;
  67. __0this -> name__4Pool = __1n ;
  68. __0this -> magic__4Pool = 62369;
  69. __0this -> nextblock__4Pool = 0 ;
  70. __0this -> curblock__4Pool = 0 ;
  71. __0this -> freelist__4Pool = 0 ;
  72. __0this -> nextfree__4Pool = 0 ;
  73. } return __0this ;
  74. }
  75. void __gl__dt__4PoolFv (struct Pool *__0this ,
  76. int __0__free )
  77. { if (__0this ){
  78. ((void )0 );
  79. while (__0this -> nextblock__4Pool ){
  80. void *__1__X5 ;
  81. ( (__1__X5 = (void *)(__0this -> blocklist__4Pool [(-- __0this -> nextblock__4Pool )])), ( (__1__X5 ?( free ( __1__X5 ) , 0 ) :(
  82. 0 ) )) ) ;
  83. (__0this -> blocklist__4Pool [__0this -> nextblock__4Pool ])= 0 ;
  84. }
  85. __0this -> magic__4Pool = 61858;
  86. if (__0this )if (__0__free & 1)( (((void *)__0this )?( free ( ((void *)__0this )) , 0 ) :( 0 ) ))
  87. ;
  88. }
  89. }
  90. void __glgrow__4PoolFv (struct Pool *__0this )
  91. {
  92. void *__1__Xp00uzigaiaa ;
  93. ((void )0 );
  94. __0this -> curblock__4Pool = (((char *)( (__1__Xp00uzigaiaa = malloc ( ((sizeof (char ))* __0this -> nextsize__4Pool )) ), (__1__Xp00uzigaiaa ?(((void *)__1__Xp00uzigaiaa )):(((void
  95. *)__1__Xp00uzigaiaa )))) ));
  96. (__0this -> blocklist__4Pool [(__0this -> nextblock__4Pool ++ )])= __0this -> curblock__4Pool ;
  97. __0this -> nextfree__4Pool = __0this -> nextsize__4Pool ;
  98. __0this -> nextsize__4Pool *= 2 ;
  99. }
  100. void __glclear__4PoolFv (struct Pool *__0this )
  101. {
  102. ((void )0 );
  103. while (__0this -> nextblock__4Pool ){
  104. void *__1__X6 ;
  105. ( (__1__X6 = (void *)(__0this -> blocklist__4Pool [(-- __0this -> nextblock__4Pool )])), ( (__1__X6 ?( free ( __1__X6 ) , 0 ) :(
  106. 0 ) )) ) ;
  107. (__0this -> blocklist__4Pool [__0this -> nextblock__4Pool ])= 0 ;
  108. }
  109. __0this -> curblock__4Pool = 0 ;
  110. __0this -> freelist__4Pool = 0 ;
  111. __0this -> nextfree__4Pool = 0 ;
  112. if (__0this -> nextsize__4Pool > __0this -> initsize__4Pool )
  113. __0this -> nextsize__4Pool /= 2 ;
  114. }
  115. /* the end */