XCache is a fast, stable PHP opcode cacher that has been proven and is now running on production servers under high load. https://xcache.lighttpd.net/
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.
 
 
 
 
 
 

57 lines
1.3 KiB

  1. #ifndef XC_VECTOR_H_0957AC4E1A44E838C7B8DBECFF9C4B3B
  2. #define XC_VECTOR_H_0957AC4E1A44E838C7B8DBECFF9C4B3B
  3. #if _MSC_VER > 1000
  4. #pragma once
  5. #endif // _MSC_VER > 1000
  6. typedef struct {
  7. zend_uint size;
  8. zend_uint cnt;
  9. void *data;
  10. } xc_vector_t;
  11. #define xc_vector_init(type, vector) do { \
  12. (vector)->cnt = 0; \
  13. (vector)->size = 0; \
  14. (vector)->data = NULL; \
  15. } while (0)
  16. #define xc_vector_add(type, vector, value) do { \
  17. if ((vector)->cnt == (vector)->size) { \
  18. if ((vector)->size) { \
  19. (vector)->size <<= 1; \
  20. (vector)->data = erealloc((vector)->data, sizeof(type) * (vector)->size); \
  21. } \
  22. else { \
  23. (vector)->size = 8; \
  24. (vector)->data = emalloc(sizeof(type) * (vector)->size); \
  25. } \
  26. } \
  27. ((type *) (vector)->data)[(vector)->cnt++] = value; \
  28. } while (0)
  29. static inline void *xc_vector_detach_impl(xc_vector_t *vector)
  30. {
  31. void *data = vector->data;
  32. vector->data = NULL;
  33. vector->size = 0;
  34. vector->cnt = 0;
  35. return data;
  36. }
  37. #define xc_vector_detach(type, vector) ((type *) xc_vector_detach_impl(vector))
  38. static inline void xc_vector_free_impl(xc_vector_t *vector TSRMLS_DC)
  39. {
  40. if (vector->data) {
  41. efree(vector->data);
  42. }
  43. vector->size = 0;
  44. vector->cnt = 0;
  45. }
  46. #define xc_vector_free(type, vector) xc_vector_free_impl(vector TSRMLS_CC)
  47. #endif /* XC_VECTOR_H_0957AC4E1A44E838C7B8DBECFF9C4B3B */