test_heap.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright (C) 2009 Mamadou Diop.
  3. *
  4. * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
  5. *
  6. * This file is part of Open Source Doubango Framework.
  7. *
  8. * DOUBANGO is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * DOUBANGO is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with DOUBANGO.
  20. *
  21. */
  22. #ifndef _TEST_HEAP_H_
  23. #define _TEST_HEAP_H_
  24. /* test heap*/
  25. void test_heap()
  26. {
  27. //int i = 0;
  28. //tsk_heap_t heap;
  29. ///* initialize our memory heap */
  30. //tsk_heap_init(&heap);
  31. ///* heap(1): Ten strings are allocated an all freed when we cleanup the heap */
  32. //for(i=0; i<10;i++)
  33. //{
  34. // char* test = tsk_strdup(&heap, "testing the heap (1)");
  35. //}
  36. //tsk_heap_cleanup(&heap);
  37. ///* heap(2): pop memory from the heap*/
  38. //{
  39. // char* test = tsk_strdup(&heap, "testing the heap (2)");
  40. // tsk_free(&heap, (void**)&test);
  41. // test = tsk_calloc(&heap, 10, 1);
  42. // tsk_free(&heap, (void**)&test);
  43. // test = tsk_malloc(&heap, 10);
  44. // tsk_free(&heap, (void**)&test);
  45. // test = tsk_malloc(&heap, 10);
  46. // test = tsk_realloc(&heap, test, 100);
  47. // tsk_free(&heap, (void**)&test);
  48. //}
  49. //
  50. ///* heap(3): pop a NULL pointer */
  51. //{
  52. // tsk_free(&heap, 0);
  53. //}
  54. ///* heap(4): allocate and pop from NULL heap */
  55. //{
  56. // char* test = tsk_calloc(0, 10, 1);
  57. // tsk_free(0, (void**)&test);
  58. // test = tsk_malloc(0, 10);
  59. // tsk_free(0, (void**)&test);
  60. // test = tsk_malloc(0, 10);
  61. // test = tsk_realloc(0, test, 100);
  62. // tsk_free(0, (void**)&test);
  63. //}
  64. }
  65. #endif /* _TEST_HEAP_H_ */