Lines Matching refs:chunk
32 mysqlnd_mempool_free_chunk(MYSQLND_MEMORY_POOL_CHUNK * chunk TSRMLS_DC) in mysqlnd_mempool_free_chunk()
34 MYSQLND_MEMORY_POOL * pool = chunk->pool; in mysqlnd_mempool_free_chunk()
36 if (chunk->from_pool) { in mysqlnd_mempool_free_chunk()
38 if (chunk->ptr == (pool->arena + (pool->arena_size - pool->free_size - chunk->size))) { in mysqlnd_mempool_free_chunk()
43 pool->free_size += chunk->size; in mysqlnd_mempool_free_chunk()
47 mnd_free(chunk->ptr); in mysqlnd_mempool_free_chunk()
49 mnd_free(chunk); in mysqlnd_mempool_free_chunk()
57 mysqlnd_mempool_resize_chunk(MYSQLND_MEMORY_POOL_CHUNK * chunk, unsigned int size TSRMLS_DC) in mysqlnd_mempool_resize_chunk() argument
60 if (chunk->from_pool) { in mysqlnd_mempool_resize_chunk()
61 MYSQLND_MEMORY_POOL * pool = chunk->pool; in mysqlnd_mempool_resize_chunk()
63 if (chunk->ptr == (pool->arena + (pool->arena_size - pool->free_size - chunk->size))) { in mysqlnd_mempool_resize_chunk()
68 if ((chunk->size + pool->free_size) < size) { in mysqlnd_mempool_resize_chunk()
74 memcpy(new_ptr, chunk->ptr, chunk->size); in mysqlnd_mempool_resize_chunk()
75 chunk->ptr = new_ptr; in mysqlnd_mempool_resize_chunk()
76 pool->free_size += chunk->size; in mysqlnd_mempool_resize_chunk()
77 chunk->size = size; in mysqlnd_mempool_resize_chunk()
78 chunk->pool = NULL; /* now we have no pool memory */ in mysqlnd_mempool_resize_chunk()
82 pool->free_size += (chunk->size - size); in mysqlnd_mempool_resize_chunk()
86 if (chunk->size >= size) { in mysqlnd_mempool_resize_chunk()
94 memcpy(new_ptr, chunk->ptr, chunk->size); in mysqlnd_mempool_resize_chunk()
95 chunk->ptr = new_ptr; in mysqlnd_mempool_resize_chunk()
96 chunk->size = size; in mysqlnd_mempool_resize_chunk()
97 chunk->pool = NULL; /* now we have non-pool memory */ in mysqlnd_mempool_resize_chunk()
102 zend_uchar *new_ptr = mnd_realloc(chunk->ptr, size); in mysqlnd_mempool_resize_chunk()
106 chunk->ptr = new_ptr; in mysqlnd_mempool_resize_chunk()
117 MYSQLND_MEMORY_POOL_CHUNK *chunk = NULL; in mysqlnd_mempool_get_chunk() local
120 chunk = mnd_malloc(sizeof(MYSQLND_MEMORY_POOL_CHUNK)); in mysqlnd_mempool_get_chunk()
121 if (chunk) { in mysqlnd_mempool_get_chunk()
122 chunk->free_chunk = mysqlnd_mempool_free_chunk; in mysqlnd_mempool_get_chunk()
123 chunk->resize_chunk = mysqlnd_mempool_resize_chunk; in mysqlnd_mempool_get_chunk()
124 chunk->size = size; in mysqlnd_mempool_get_chunk()
130 chunk->pool = pool; in mysqlnd_mempool_get_chunk()
132 chunk->from_pool = FALSE; in mysqlnd_mempool_get_chunk()
133 chunk->ptr = mnd_malloc(size); in mysqlnd_mempool_get_chunk()
134 if (!chunk->ptr) { in mysqlnd_mempool_get_chunk()
135 chunk->free_chunk(chunk TSRMLS_CC); in mysqlnd_mempool_get_chunk()
136 chunk = NULL; in mysqlnd_mempool_get_chunk()
139 chunk->from_pool = TRUE; in mysqlnd_mempool_get_chunk()
141 chunk->ptr = pool->arena + (pool->arena_size - pool->free_size); in mysqlnd_mempool_get_chunk()
146 DBG_RETURN(chunk); in mysqlnd_mempool_get_chunk()