You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ngx_rbtree_t, a red-black tree. This structure is used both as intrusive (ngx_event_t.timer of type ngx_rbtree_node_t) and via ngx_rbtree_node_t.data of type void *.
All of those should be representable as strictly typed objects, e.g. Array<NgxStr>, List<TableElement>, Hash<HttpHeader> and have the necessary iteration, random access and modification methods. This way we could limit unsafety to the initialization of a collection wrapper.
There's a crate that is useful for implementing such wrappers, foreign-types. It's not necessary, as for Array<T> we can directly cast ngx_array_t.elts.add(i) to *mut T with almost the same level of (un)safety, but it makes certain steps easier and reduces boilerplate code.
The text was updated successfully, but these errors were encountered:
In NGINX we have several "generic" collections (in the most C style of generic, with
void *
or pointer aliasing):ngx_array_t
, an array of known-sizevoid *
pointersngx_list_t
, a sequence of arrays ofvoid *
ngx_queue_t
, an intrusive doubly linked list.ngx_rbtree_t
, a red-black tree. This structure is used both as intrusive (ngx_event_t.timer
of typengx_rbtree_node_t
) and viangx_rbtree_node_t.data
of typevoid *
.ngx_hash_t
, a hash table.All of those should be representable as strictly typed objects, e.g.
Array<NgxStr>
,List<TableElement>
,Hash<HttpHeader>
and have the necessary iteration, random access and modification methods. This way we could limit unsafety to the initialization of a collection wrapper.There's a crate that is useful for implementing such wrappers,
foreign-types
. It's not necessary, as forArray<T>
we can directly castngx_array_t.elts.add(i)
to*mut T
with almost the same level of (un)safety, but it makes certain steps easier and reduces boilerplate code.The text was updated successfully, but these errors were encountered: