zend_static_allocator.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. +----------------------------------------------------------------------+
  3. | Zend Engine |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1998-2016 Zend Technologies Ltd. (http://www.zend.com) |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 2.00 of the Zend license, |
  8. | that is bundled with this package in the file LICENSE, and is |
  9. | available through the world-wide-web at the following url: |
  10. | http://www.zend.com/license/2_00.txt. |
  11. | If you did not receive a copy of the Zend license and are unable to |
  12. | obtain it through the world-wide-web, please send a note to |
  13. | license@zend.com so we can mail you a copy immediately. |
  14. +----------------------------------------------------------------------+
  15. | Authors: Andi Gutmans <andi@zend.com> |
  16. +----------------------------------------------------------------------+
  17. */
  18. /* $Id$ */
  19. #ifndef ZEND_STATIC_ALLOCATOR_H
  20. #define ZEND_STATIC_ALLOCATOR_H
  21. #define ALLOCATOR_BLOCK_SIZE 400000
  22. /* Temporary */
  23. typedef unsigned int zend_uint;
  24. #define emalloc(s) malloc(s)
  25. #define efree(p) free(p)
  26. typedef struct _Block {
  27. char *bp;
  28. char *pos;
  29. char *end;
  30. } Block;
  31. typedef struct _StaticAllocator {
  32. Block *Blocks;
  33. zend_uint num_blocks;
  34. zend_uint current_block;
  35. } StaticAllocator;
  36. void static_allocator_init(StaticAllocator *sa);
  37. char *static_allocator_allocate(StaticAllocator *sa, zend_uint size);
  38. void static_allocator_destroy(StaticAllocator *sa);
  39. #endif /* ZEND_STATIC_ALLOCATOR_H */
  40. /*
  41. * Local variables:
  42. * tab-width: 4
  43. * c-basic-offset: 4
  44. * indent-tabs-mode: t
  45. * End:
  46. */