php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
mysqlnd_block_alloc.c
Go to the documentation of this file.
1/*
2 +----------------------------------------------------------------------+
3 | Copyright (c) The PHP Group |
4 +----------------------------------------------------------------------+
5 | This source file is subject to version 3.01 of the PHP 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 | https://www.php.net/license/3_01.txt |
9 | If you did not receive a copy of the PHP license and are unable to |
10 | obtain it through the world-wide-web, please send a note to |
11 | license@php.net so we can mail you a copy immediately. |
12 +----------------------------------------------------------------------+
13 | Authors: Andrey Hristov <andrey@php.net> |
14 | Ulf Wendel <uw@php.net> |
15 | Dmitry Stogov <dmitry@php.net> |
16 +----------------------------------------------------------------------+
17*/
18
19#include "php.h"
20#include "mysqlnd.h"
21#include "mysqlnd_block_alloc.h"
22#include "mysqlnd_debug.h"
23#include "mysqlnd_priv.h"
24
25/* {{{ mysqlnd_mempool_get_chunk */
26static void *
27mysqlnd_mempool_get_chunk(MYSQLND_MEMORY_POOL * pool, size_t size)
28{
29 DBG_ENTER("mysqlnd_mempool_get_chunk");
30 DBG_RETURN(zend_arena_alloc(&pool->arena, size));
31}
32/* }}} */
33
34
35/* {{{ mysqlnd_mempool_create */
37mysqlnd_mempool_create(size_t arena_size)
38{
41
42 DBG_ENTER("mysqlnd_mempool_create");
43 arena = zend_arena_create(MAX(arena_size, ZEND_MM_ALIGNED_SIZE(sizeof(zend_arena))));
44 ret = zend_arena_alloc(&arena, sizeof(MYSQLND_MEMORY_POOL));
45 ret->arena = arena;
46 ret->checkpoint = NULL;
47 ret->get_chunk = mysqlnd_mempool_get_chunk;
49}
50/* }}} */
51
52
53/* {{{ mysqlnd_mempool_destroy */
54PHPAPI void
56{
57 DBG_ENTER("mysqlnd_mempool_destroy");
58 /* mnd_free will reference LOCK_access and might crash, depending on the caller...*/
59 zend_arena_destroy(pool->arena);
61}
62/* }}} */
63
64/* {{{ mysqlnd_mempool_save_state */
65PHPAPI void
67{
68 DBG_ENTER("mysqlnd_mempool_save_state");
69 pool->checkpoint = zend_arena_checkpoint(pool->arena);
71}
72/* }}} */
73
74/* {{{ mysqlnd_mempool_restore_state */
75PHPAPI void
77{
78 DBG_ENTER("mysqlnd_mempool_restore_state");
79#if ZEND_DEBUG
81#endif
82 if (pool->checkpoint) {
83 zend_arena_release(&pool->arena, pool->checkpoint);
84 pool->checkpoint = NULL;
85 }
87}
88/* }}} */
new_type size
Definition ffi.c:4365
#define NULL
Definition gdcache.h:45
PHPAPI void mysqlnd_mempool_destroy(MYSQLND_MEMORY_POOL *pool)
PHPAPI void mysqlnd_mempool_restore_state(MYSQLND_MEMORY_POOL *pool)
PHPAPI void mysqlnd_mempool_save_state(MYSQLND_MEMORY_POOL *pool)
PHPAPI MYSQLND_MEMORY_POOL * mysqlnd_mempool_create(size_t arena_size)
#define DBG_VOID_RETURN
#define DBG_RETURN(value)
struct st_mysqlnd_memory_pool MYSQLND_MEMORY_POOL
#define PHPAPI
Definition php.h:71
char * arena
Definition php_bcmath.h:37
#define ZEND_MM_ALIGNED_SIZE(size)
Definition zend_alloc.h:35
struct _zend_arena zend_arena
Definition zend_arena.h:26
#define ZEND_ASSERT(c)
#define MAX(a, b)
zval * ret