php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
fpm_cleanup.c
Go to the documentation of this file.
1 /* (c) 2007,2008 Andrei Nigmatulin */
2
3#include "fpm_config.h"
4
5#include <stdlib.h>
6
7#include "fpm_arrays.h"
8#include "fpm_cleanup.h"
9
10struct cleanup_s {
11 int type;
12 void (*cleanup)(int, void *);
13 void *arg;
14};
15
16static struct fpm_array_s cleanups = { .sz = sizeof(struct cleanup_s) };
17
18int fpm_cleanup_add(int type, void (*cleanup)(int, void *), void *arg) /* {{{ */
19{
20 struct cleanup_s *c;
21
22 c = fpm_array_push(&cleanups);
23
24 if (!c) {
25 return -1;
26 }
27
28 c->type = type;
29 c->cleanup = cleanup;
30 c->arg = arg;
31
32 return 0;
33}
34/* }}} */
35
36void fpm_cleanups_run(int type) /* {{{ */
37{
38 struct cleanup_s *c = fpm_array_item_last(&cleanups);
39 int cl = cleanups.used;
40
41 for ( ; cl--; c--) {
42 if (c->type & type) {
43 c->cleanup(type, c->arg);
44 }
45 }
46
47 fpm_array_free(&cleanups);
48}
49/* }}} */
zend_ffi_type * type
Definition ffi.c:3812
zval * arg
Definition ffi.c:3975
int fpm_cleanup_add(int type, void(*cleanup)(int, void *), void *arg)
Definition fpm_cleanup.c:18
void fpm_cleanups_run(int type)
Definition fpm_cleanup.c:36
void * arg
Definition fpm_cleanup.c:13
void(* cleanup)(int, void *)
Definition fpm_cleanup.c:12
ZEND_API void(ZEND_FASTCALL *zend_touch_vm_stack_data)(void *vm_stack_data)