xref: /PHP-8.0/Zend/zend_weakrefs.h (revision 471102ed)
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 
17 #ifndef ZEND_WEAKREFS_H
18 #define ZEND_WEAKREFS_H
19 
20 BEGIN_EXTERN_C()
21 
22 extern ZEND_API zend_class_entry *zend_ce_weakref;
23 
24 void zend_register_weakref_ce(void);
25 
26 void zend_weakrefs_init(void);
27 void zend_weakrefs_shutdown(void);
28 
29 ZEND_API void zend_weakrefs_notify(zend_object *object);
30 
31 ZEND_API zval *zend_weakrefs_hash_add(HashTable *ht, zend_object *key, zval *pData);
32 ZEND_API zend_result zend_weakrefs_hash_del(HashTable *ht, zend_object *key);
zend_weakrefs_hash_add_ptr(HashTable * ht,zend_object * key,void * ptr)33 static zend_always_inline void *zend_weakrefs_hash_add_ptr(HashTable *ht, zend_object *key, void *ptr) {
34 	zval tmp, *zv;
35 	ZVAL_PTR(&tmp, ptr);
36 	if ((zv = zend_weakrefs_hash_add(ht, key, &tmp))) {
37 		return Z_PTR_P(zv);
38 	} else {
39 		return NULL;
40 	}
41 }
42 
43 END_EXTERN_C()
44 
45 #endif
46 
47