Open Source Tomb Raider Engine
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

memory_test.cpp 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
  2. /*================================================================
  3. *
  4. * Project : MTK
  5. * Author : Terry 'Mongoose' Hendrix II
  6. * Website : http://www.westga.edu/~stu7440/
  7. * Email : stu7440@westga.edu
  8. * Object : memory_test
  9. * License : No use w/o permission (C) 2002 Mongoose
  10. * Comments: Memory testing tool kit
  11. *
  12. *
  13. * This file was generated using Mongoose's C++
  14. * template generator script. <stu7440@westga.edu>
  15. *
  16. *-- History -------------------------------------------------
  17. *
  18. * 2002.03.27:
  19. * Mongoose - Created
  20. =================================================================*/
  21. #include <string.h>
  22. #include <stdio.h>
  23. #include <stdlib.h>
  24. #include <memory_test.h>
  25. extern rbtree_t *MEMORY_INFO;
  26. extern meminfo_filename_t *MEMORY_FILENAME;
  27. extern long MEMORY_USED;
  28. extern long MEMORYA_USED;
  29. extern long MEMORYC_USED;
  30. extern long MAX_MEMORY_USED;
  31. extern long MAX_MEMORYA_USED;
  32. extern long MAX_MEMORYC_USED;
  33. void tree_valid_report(rbtree_t *root);
  34. #define PRINT_TEST_BREAK_LINE printf("\n############################################################\n\n");
  35. int memory_test_unit_test(int argc, char *argv[])
  36. {
  37. int *i, *j, *k, *l, *m, *n, *o;
  38. PRINT_TEST_BREAK_LINE
  39. printf("Memory test\n");
  40. PRINT_TEST_BREAK_LINE
  41. i = new int;
  42. printf(">\ti = new int; (%p) %s:%i\n", i, __FILE__, __LINE__);
  43. dump_memory_report();
  44. tree_valid_report(MEMORY_INFO);
  45. delete i;
  46. printf(">\tdelete i; (%p) %s:%i\n", i, __FILE__, __LINE__);
  47. dump_memory_report();
  48. tree_valid_report(MEMORY_INFO);
  49. PRINT_TEST_BREAK_LINE
  50. i = new int[3];
  51. printf(">\ti = new int[3]; (%p) %s:%i\n", i, __FILE__, __LINE__);
  52. dump_memory_report();
  53. tree_valid_report(MEMORY_INFO);
  54. delete [] i;
  55. printf(">\tdelete [] i; (%p) %s:%i\n", i, __FILE__, __LINE__);
  56. dump_memory_report();
  57. tree_valid_report(MEMORY_INFO);
  58. PRINT_TEST_BREAK_LINE
  59. i = new int[3];
  60. printf(">\ti = new int[3]; (%p) %s:%i\n", i, __FILE__, __LINE__);
  61. j = new int;
  62. printf(">\tj = new int; (%p) %s:%i\n", j, __FILE__, __LINE__);
  63. k = new int[3];
  64. printf(">\tk = new int[3]; (%p) %s:%i\n", k, __FILE__, __LINE__);
  65. dump_memory_report();
  66. tree_valid_report(MEMORY_INFO);
  67. delete [] i;
  68. printf(">\tdelete [] i; (%p) %s:%i\n", i, __FILE__, __LINE__);
  69. delete j;
  70. printf(">\tdelete j; (%p) %s:%i\n", j, __FILE__, __LINE__);
  71. delete [] k;
  72. printf(">\tdelete [] k; (%p) %s:%i\n", k, __FILE__, __LINE__);
  73. dump_memory_report();
  74. tree_valid_report(MEMORY_INFO);
  75. PRINT_TEST_BREAK_LINE
  76. i = new int[3];
  77. printf(">\ti = new int[3]; (%p) %s:%i\n", i, __FILE__, __LINE__);
  78. j = new int;
  79. printf(">\tj = new int; (%p) %s:%i\n", j, __FILE__, __LINE__);
  80. k = new int[3];
  81. printf(">\tk = new int[3]; (%p) %s:%i\n", k, __FILE__, __LINE__);
  82. dump_memory_report();
  83. tree_valid_report(MEMORY_INFO);
  84. delete j;
  85. printf(">\tdelete j; (%p) %s:%i\n", j, __FILE__, __LINE__);
  86. dump_memory_report();
  87. tree_valid_report(MEMORY_INFO);
  88. j = new int[3];
  89. printf(">\tj = new int[3]; (%p) %s:%i\n", j, __FILE__, __LINE__);
  90. dump_memory_report();
  91. tree_valid_report(MEMORY_INFO);
  92. l = new int[3];
  93. printf(">\tl = new int[3]; (%p) %s:%i\n", l, __FILE__, __LINE__);
  94. dump_memory_report();
  95. tree_valid_report(MEMORY_INFO);
  96. m = new int[3];
  97. printf(">\tm = new int[3]; (%p) %s:%i\n", m, __FILE__, __LINE__);
  98. dump_memory_report();
  99. tree_valid_report(MEMORY_INFO);
  100. n = new int[3];
  101. printf(">\tn = new int[3]; (%p) %s:%i\n", n, __FILE__, __LINE__);
  102. dump_memory_report();
  103. tree_valid_report(MEMORY_INFO);
  104. o = new int[3];
  105. printf(">\to = new int[3]; (%p) %s:%i\n", o, __FILE__, __LINE__);
  106. dump_memory_report();
  107. tree_valid_report(MEMORY_INFO);
  108. delete [] k;
  109. printf(">\tdelete [] k; (%p) %s:%i\n", k, __FILE__, __LINE__);
  110. dump_memory_report();
  111. tree_valid_report(MEMORY_INFO);
  112. delete [] j;
  113. printf(">\tdelete [] j; (%p) %s:%i\n", j, __FILE__, __LINE__);
  114. dump_memory_report();
  115. tree_valid_report(MEMORY_INFO);
  116. delete [] l;
  117. printf(">\tdelete [] l; (%p) %s:%i\n", l, __FILE__, __LINE__);
  118. dump_memory_report();
  119. tree_valid_report(MEMORY_INFO);
  120. delete [] m;
  121. printf(">\tdelete [] m; (%p) %s:%i\n", m, __FILE__, __LINE__);
  122. dump_memory_report();
  123. tree_valid_report(MEMORY_INFO);
  124. delete [] n;
  125. printf(">\tdelete [] n; (%p) %s:%i\n", n, __FILE__, __LINE__);
  126. dump_memory_report();
  127. tree_valid_report(MEMORY_INFO);
  128. delete [] o;
  129. printf(">\tdelete [] o; (%p) %s:%i\n", o, __FILE__, __LINE__);
  130. dump_memory_report();
  131. tree_valid_report(MEMORY_INFO);
  132. delete [] i;
  133. printf(">\tdelete [] i; (%p) %s:%i\n", i, __FILE__, __LINE__);
  134. dump_memory_report();
  135. tree_valid_report(MEMORY_INFO);
  136. PRINT_TEST_BREAK_LINE
  137. return 0;
  138. }
  139. int main(int argc, char *argv[])
  140. {
  141. printf("[memory_test test]\n");
  142. return memory_test_unit_test(argc, argv);
  143. }