Resources/Lists
Resources Lists
int zend_register_list_destructors(void (*ld)(void *), void (*pld)(void *), int module_number); int zend_register_list_destructors_ex(rsrc_dtor_func_t ld, rsrc_dtor_func_t pld, char *type_name, int module_number);
Registers a list entry and associate destructors with it. When an entry using the associated list type is removed from EG(reuglar_list), the non-persistent ld destructor function will be called. When such a persistent entry is removed, the pld destructor will be called instead.
Argument |
Purpose |
---|---|
ld |
Non-persistent destructor method. |
pld |
Persistent destructor method. |
type_name |
Descriptive name for the resource type. |
module_number |
Hint to the engine on who owns this resource type. Should be passed unmodified from an MINIT method. |
int zend_list_insert(void *ptr, int type); int zend_register_resource(zval *result, void *ptr, int type);
Places a resource pointer into the EG(regular_list) HashTable and returns a numeric resource ID. zend_register_resource() goes an extra step further and populates that resource ID into a ZVAL for passing back to userspace code.
Argument |
Purpose |
---|---|
ptr |
Arbitrary pointer resource to store |
type |
Registered type to associate with the resource and use for later destruction |
result zval |
to populate with the resource ID |
int zend_list_addref(int id); int zend_list_delete(int id);
Increases or decreases a given resource ID's reference count. Note that zend_list_delete() does not hard delete the resource, it only decreases the refcount and deletes in the event that refcount reaches zero.
void *zend_list_find(int id, int *type); void *zend_fetch_resource(zval **zval_id TSRMLS_DC, int id, char *type_name, int *type, int num_types, ...);
Retrieves a resource from EG(regular_list) using the passed id or zval_id. The resource will be returned as a pointer or NULL if no matching resource can be found.
Argument |
Purpose |
---|---|
id |
Numeric resource ID to locate. |
zval_id |
If id is passed as -1, look for the resource ID encoded into this zval. |
type |
Populated with the numeric resource type located. |
type_name |
Populated with the textual name of the resource type located. |
num_types |
Number of valid resource types to match against this resource. |
... |
List of expected resource types. If the located resource does not match one of these types, it will not be considered a match. |
int zend_fetch_list_dtor_id(char *type_name);
Returns the numeric resource type based on the requested type name.
char *zend_rsrc_list_get_rsrc_type(int resource TSRMLS_DC);
Returns the type name of the specified resource ID.