zend_weakrefs.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. +----------------------------------------------------------------------+
  3. | Copyright (c) The PHP Group |
  4. +----------------------------------------------------------------------+
  5. | This source file is subject to version 2.00 of the Zend license, |
  6. | that is bundled with this package in the file LICENSE, and is |
  7. | available through the world-wide-web at the following url: |
  8. | http://www.zend.com/license/2_00.txt. |
  9. | If you did not receive a copy of the Zend license and are unable to |
  10. | obtain it through the world-wide-web, please send a note to |
  11. | license@zend.com so we can mail you a copy immediately. |
  12. +----------------------------------------------------------------------+
  13. | Authors: krakjoe@php.net |
  14. +----------------------------------------------------------------------+
  15. */
  16. #ifndef ZEND_WEAKREFS_H
  17. #define ZEND_WEAKREFS_H
  18. BEGIN_EXTERN_C()
  19. extern ZEND_API zend_class_entry *zend_ce_weakref;
  20. void zend_register_weakref_ce(void);
  21. void zend_weakrefs_init(void);
  22. void zend_weakrefs_shutdown(void);
  23. ZEND_API void zend_weakrefs_notify(zend_object *object);
  24. ZEND_API zval *zend_weakrefs_hash_add(HashTable *ht, zend_object *key, zval *pData);
  25. ZEND_API zend_result zend_weakrefs_hash_del(HashTable *ht, zend_object *key);
  26. static zend_always_inline void *zend_weakrefs_hash_add_ptr(HashTable *ht, zend_object *key, void *ptr) {
  27. zval tmp, *zv;
  28. ZVAL_PTR(&tmp, ptr);
  29. if ((zv = zend_weakrefs_hash_add(ht, key, &tmp))) {
  30. return Z_PTR_P(zv);
  31. } else {
  32. return NULL;
  33. }
  34. }
  35. END_EXTERN_C()
  36. #endif