@@ -101,8 +101,8 @@ impl Pool {
101
101
///
102
102
/// Returns `Some(TemporaryBuffer)` if the buffer is successfully created, or `None` if
103
103
/// allocation fails.
104
- pub fn create_buffer ( & mut self , size : usize ) -> Option < TemporaryBuffer > {
105
- let buf = unsafe { ngx_create_temp_buf ( self . as_mut ( ) , size) } ;
104
+ pub fn create_buffer ( & self , size : usize ) -> Option < TemporaryBuffer > {
105
+ let buf = unsafe { ngx_create_temp_buf ( self . 0 . as_ptr ( ) , size) } ;
106
106
if buf. is_null ( ) {
107
107
return None ;
108
108
}
@@ -114,7 +114,7 @@ impl Pool {
114
114
///
115
115
/// Returns `Some(TemporaryBuffer)` if the buffer is successfully created, or `None` if
116
116
/// allocation fails.
117
- pub fn create_buffer_from_str ( & mut self , str : & str ) -> Option < TemporaryBuffer > {
117
+ pub fn create_buffer_from_str ( & self , str : & str ) -> Option < TemporaryBuffer > {
118
118
let mut buffer = self . create_buffer ( str. len ( ) ) ?;
119
119
unsafe {
120
120
let buf = buffer. as_ngx_buf_mut ( ) ;
@@ -128,7 +128,7 @@ impl Pool {
128
128
///
129
129
/// Returns `Some(MemoryBuffer)` if the buffer is successfully created, or `None` if allocation
130
130
/// fails.
131
- pub fn create_buffer_from_static_str ( & mut self , str : & ' static str ) -> Option < MemoryBuffer > {
131
+ pub fn create_buffer_from_static_str ( & self , str : & ' static str ) -> Option < MemoryBuffer > {
132
132
let buf = self . calloc_type :: < ngx_buf_t > ( ) ;
133
133
if buf. is_null ( ) {
134
134
return None ;
@@ -156,7 +156,7 @@ impl Pool {
156
156
///
157
157
/// # Safety
158
158
/// This function is marked as unsafe because it involves raw pointer manipulation.
159
- unsafe fn add_cleanup_for_value < T > ( & mut self , value : * mut T ) -> Result < ( ) , ( ) > {
159
+ unsafe fn add_cleanup_for_value < T > ( & self , value : * mut T ) -> Result < ( ) , ( ) > {
160
160
let cln = ngx_pool_cleanup_add ( self . 0 . as_ptr ( ) , 0 ) ;
161
161
if cln. is_null ( ) {
162
162
return Err ( ( ) ) ;
@@ -171,45 +171,45 @@ impl Pool {
171
171
/// The resulting pointer is aligned to a platform word size.
172
172
///
173
173
/// Returns a raw pointer to the allocated memory.
174
- pub fn alloc ( & mut self , size : usize ) -> * mut c_void {
174
+ pub fn alloc ( & self , size : usize ) -> * mut c_void {
175
175
unsafe { ngx_palloc ( self . 0 . as_ptr ( ) , size) }
176
176
}
177
177
178
178
/// Allocates memory for a type from the pool.
179
179
/// The resulting pointer is aligned to a platform word size.
180
180
///
181
181
/// Returns a typed pointer to the allocated memory.
182
- pub fn alloc_type < T : Copy > ( & mut self ) -> * mut T {
182
+ pub fn alloc_type < T : Copy > ( & self ) -> * mut T {
183
183
self . alloc ( mem:: size_of :: < T > ( ) ) as * mut T
184
184
}
185
185
186
186
/// Allocates zeroed memory from the pool of the specified size.
187
187
/// The resulting pointer is aligned to a platform word size.
188
188
///
189
189
/// Returns a raw pointer to the allocated memory.
190
- pub fn calloc ( & mut self , size : usize ) -> * mut c_void {
190
+ pub fn calloc ( & self , size : usize ) -> * mut c_void {
191
191
unsafe { ngx_pcalloc ( self . 0 . as_ptr ( ) , size) }
192
192
}
193
193
194
194
/// Allocates zeroed memory for a type from the pool.
195
195
/// The resulting pointer is aligned to a platform word size.
196
196
///
197
197
/// Returns a typed pointer to the allocated memory.
198
- pub fn calloc_type < T : Copy > ( & mut self ) -> * mut T {
198
+ pub fn calloc_type < T : Copy > ( & self ) -> * mut T {
199
199
self . calloc ( mem:: size_of :: < T > ( ) ) as * mut T
200
200
}
201
201
202
202
/// Allocates unaligned memory from the pool of the specified size.
203
203
///
204
204
/// Returns a raw pointer to the allocated memory.
205
- pub fn alloc_unaligned ( & mut self , size : usize ) -> * mut c_void {
205
+ pub fn alloc_unaligned ( & self , size : usize ) -> * mut c_void {
206
206
unsafe { ngx_pnalloc ( self . 0 . as_ptr ( ) , size) }
207
207
}
208
208
209
209
/// Allocates unaligned memory for a type from the pool.
210
210
///
211
211
/// Returns a typed pointer to the allocated memory.
212
- pub fn alloc_type_unaligned < T : Copy > ( & mut self ) -> * mut T {
212
+ pub fn alloc_type_unaligned < T : Copy > ( & self ) -> * mut T {
213
213
self . alloc_unaligned ( mem:: size_of :: < T > ( ) ) as * mut T
214
214
}
215
215
@@ -218,7 +218,7 @@ impl Pool {
218
218
///
219
219
/// Returns a typed pointer to the allocated memory if successful, or a null pointer if
220
220
/// allocation or cleanup handler addition fails.
221
- pub fn allocate < T > ( & mut self , value : T ) -> * mut T {
221
+ pub fn allocate < T > ( & self , value : T ) -> * mut T {
222
222
unsafe {
223
223
let p = self . alloc ( mem:: size_of :: < T > ( ) ) as * mut T ;
224
224
ptr:: write ( p, value) ;
0 commit comments