/opengles/src/codegen/heap.h

http://ftk.googlecode.com/ · C Header · 76 lines · 19 code · 17 blank · 40 comment · 1 complexity · e3bc91f4f1250b675d61f535f7b6cd79 MD5 · raw file

  1. #ifndef CODEGEN_HEAP_H
  2. #define CODEGEN_HEAP_H 1
  3. /****************************************************************************/
  4. /* */
  5. /* Copyright (c) 2004, Hans-Martin Will. All rights reserved. */
  6. /* */
  7. /* Redistribution and use in source and binary forms, with or without */
  8. /* modification, are permitted provided that the following conditions are */
  9. /* met: */
  10. /* */
  11. /* * Redistributions of source code must retain the above copyright */
  12. /* notice, this list of conditions and the following disclaimer. */
  13. /* */
  14. /* * Redistributions in binary form must reproduce the above copyright */
  15. /* notice, this list of conditions and the following disclaimer in the */
  16. /* documentation and/or other materials provided with the distribution. */
  17. /* */
  18. /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
  19. /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
  20. /* LIMITED TO, THEIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
  21. /* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER */
  22. /* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, */
  23. /* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, */
  24. /* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR */
  25. /* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
  26. /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
  27. /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
  28. /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
  29. /* */
  30. /****************************************************************************/
  31. #include "codegen.h"
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. /****************************************************************************/
  36. /* Heap data type */
  37. /****************************************************************************/
  38. #if defined(__GCC32__) && defined(__cplusplus)
  39. struct cg_heap_t;
  40. #else
  41. typedef struct cg_heap_t cg_heap_t;
  42. #endif
  43. cg_heap_t * cg_heap_create(size_t default_block_size);
  44. /************************************************************************/
  45. /* Create a new heap object. */
  46. /************************************************************************/
  47. void cg_heap_destroy(cg_heap_t * heap);
  48. /************************************************************************/
  49. /* Destroy a heap and deallocate any memory belonging to it */
  50. /************************************************************************/
  51. void * cg_heap_allocate(cg_heap_t * heap, size_t amount);
  52. /************************************************************************/
  53. /* Allocate a block of memory of the given size on the heap. */
  54. /************************************************************************/
  55. #define NEW(Heap,Type) ((Type *) CG_Allocate(Heap, sizeof(Type)))
  56. #ifdef __cplusplus
  57. }
  58. #endif
  59. #endif //ndef CODEGEN_HEAP_H