@@ -101,8 +101,8 @@ impl Pool {
101101 ///
102102 /// Returns `Some(TemporaryBuffer)` if the buffer is successfully created, or `None` if
103103 /// 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) } ;
106106 if buf. is_null ( ) {
107107 return None ;
108108 }
@@ -114,7 +114,7 @@ impl Pool {
114114 ///
115115 /// Returns `Some(TemporaryBuffer)` if the buffer is successfully created, or `None` if
116116 /// 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 > {
118118 let mut buffer = self . create_buffer ( str. len ( ) ) ?;
119119 unsafe {
120120 let buf = buffer. as_ngx_buf_mut ( ) ;
@@ -128,7 +128,7 @@ impl Pool {
128128 ///
129129 /// Returns `Some(MemoryBuffer)` if the buffer is successfully created, or `None` if allocation
130130 /// 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 > {
132132 let buf = self . calloc_type :: < ngx_buf_t > ( ) ;
133133 if buf. is_null ( ) {
134134 return None ;
@@ -156,7 +156,7 @@ impl Pool {
156156 ///
157157 /// # Safety
158158 /// 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 < ( ) , ( ) > {
160160 let cln = ngx_pool_cleanup_add ( self . 0 . as_ptr ( ) , 0 ) ;
161161 if cln. is_null ( ) {
162162 return Err ( ( ) ) ;
@@ -171,45 +171,45 @@ impl Pool {
171171 /// The resulting pointer is aligned to a platform word size.
172172 ///
173173 /// 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 {
175175 unsafe { ngx_palloc ( self . 0 . as_ptr ( ) , size) }
176176 }
177177
178178 /// Allocates memory for a type from the pool.
179179 /// The resulting pointer is aligned to a platform word size.
180180 ///
181181 /// 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 {
183183 self . alloc ( mem:: size_of :: < T > ( ) ) as * mut T
184184 }
185185
186186 /// Allocates zeroed memory from the pool of the specified size.
187187 /// The resulting pointer is aligned to a platform word size.
188188 ///
189189 /// 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 {
191191 unsafe { ngx_pcalloc ( self . 0 . as_ptr ( ) , size) }
192192 }
193193
194194 /// Allocates zeroed memory for a type from the pool.
195195 /// The resulting pointer is aligned to a platform word size.
196196 ///
197197 /// 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 {
199199 self . calloc ( mem:: size_of :: < T > ( ) ) as * mut T
200200 }
201201
202202 /// Allocates unaligned memory from the pool of the specified size.
203203 ///
204204 /// 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 {
206206 unsafe { ngx_pnalloc ( self . 0 . as_ptr ( ) , size) }
207207 }
208208
209209 /// Allocates unaligned memory for a type from the pool.
210210 ///
211211 /// 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 {
213213 self . alloc_unaligned ( mem:: size_of :: < T > ( ) ) as * mut T
214214 }
215215
@@ -218,7 +218,7 @@ impl Pool {
218218 ///
219219 /// Returns a typed pointer to the allocated memory if successful, or a null pointer if
220220 /// 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 {
222222 unsafe {
223223 let p = self . alloc ( mem:: size_of :: < T > ( ) ) as * mut T ;
224224 ptr:: write ( p, value) ;
0 commit comments