File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -183,6 +183,34 @@ pub fn ngx_timeofday() -> &'static ngx_time_t {
183
183
unsafe { & * ngx_cached_time }
184
184
}
185
185
186
+ /// Initialize a list, using a pool for the backing memory, with capacity to store the given number
187
+ /// of elements and element size.
188
+ ///
189
+ /// # Safety
190
+ /// * `list` must be non-null
191
+ /// * `pool` must be a valid pool
192
+ #[ inline]
193
+ pub unsafe fn ngx_list_init (
194
+ list : * mut ngx_list_t ,
195
+ pool : * mut ngx_pool_t ,
196
+ n : ngx_uint_t ,
197
+ size : usize ,
198
+ ) -> ngx_int_t {
199
+ unsafe {
200
+ ( * list) . part . elts = ngx_palloc ( pool, n * size) ;
201
+ if ( * list) . part . elts . is_null ( ) {
202
+ return NGX_ERROR as ngx_int_t ;
203
+ }
204
+ ( * list) . part . nelts = 0 ;
205
+ ( * list) . part . next = core:: ptr:: null_mut ( ) ;
206
+ ( * list) . last = core:: ptr:: from_mut ( & mut ( * list) . part ) ;
207
+ ( * list) . size = size;
208
+ ( * list) . nalloc = n;
209
+ ( * list) . pool = pool;
210
+ NGX_OK as ngx_int_t
211
+ }
212
+ }
213
+
186
214
/// Add a key-value pair to an nginx table entry (`ngx_table_elt_t`) in the given nginx memory pool.
187
215
///
188
216
/// # Arguments
You can’t perform that action at this time.
0 commit comments